Merge pull request #3941 from inspec/cw/add-inspec-habitat-to-docs

Add inspec-habitat resources to website docs
This commit is contained in:
Clinton Wolfe 2019-04-12 09:49:45 -04:00 committed by GitHub
commit 70adab14cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -15,3 +15,8 @@ resource_packs:
git_repo: https://github.com/inspec/inspec-azure.git
doc_group_title: Azure
resource_file_regex: ^azure
inspec-habitat:
git_repo: https://github.com/inspec/inspec-habitat.git
doc_group_title: Habitat
resource_file_regex: ^habitat_

View file

@ -168,7 +168,7 @@ class ResourceDocs
# doc_file looks like /resources/foo.md.erb - trim off directory and file extension
trimmed_doc_files = resource_doc_files.dup.map { |file| File.basename(file).sub(/\.md(\.erb)?$/, '') }
resources_by_group = Hash[group_regexes.map { |info| [info[:group_name], []] }] # Initialize each group to an empty array
resources_by_group['OS resources'] = []
resources_by_group['OS'] = []
trimmed_doc_files.each do |doc_file|
matched = false
group_regexes.each do |group_info|
@ -179,7 +179,7 @@ class ResourceDocs
end
end
# Any resources that don't match a regex are assumed to be 'os' resources.
resources_by_group['OS resources'] << doc_file unless matched
resources_by_group['OS'] << doc_file unless matched
end
# Now transform the resource lists into HTML
@ -196,7 +196,7 @@ class ResourceDocs
# Generate the big buttons that jump to the section of the page for each group.
markdown << '<div class="row columns align">'
# "Sorted, except OS is always in first place"
ordered_group_names = ['OS resources'] + resources_by_group.keys.sort.reject { |group_name| group_name == 'OS resources' }
ordered_group_names = ['OS'] + resources_by_group.keys.sort.reject { |group_name| group_name == 'OS' }
button_template = '<a class="resources-button button btn-lg btn-purple-o shadow margin-right-xs" href="%s">%s</a>'
ordered_group_names.each do |group_name|
markdown << format(button_template, '#'+(group_name+'-resources').downcase, group_name)