Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/puppet_references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def self.build_puppet_references(commit)
]
config = PuppetReferences::Config.read
repo = PuppetReferences::Repo.new('openvox', PUPPET_DIR, nil, config['puppet']['repo'])
version_commit = commit || repo.describe.split('-')[0]
puts "Using tag #{version_commit}"
real_commit = repo.checkout(version_commit)
$version_commit = commit || repo.describe.split('-')[0]
puts "Using tag #{$version_commit}"
real_commit = repo.checkout($version_commit)
repo.update_bundle
build_from_list_of_classes(references, real_commit)
end
Expand All @@ -57,13 +57,13 @@ def self.build_facter_references(commit)
# we need the CLI docs for 3.y. We can remove this when we stop building 3.y.
version4 = Gem::Version.create('4.0.0')
repo = PuppetReferences::Repo.new('openfact', FACTER_DIR)
version_commit = commit || repo.describe.split('-')[0]
puts "Using tag #{version_commit}"
real_commit = repo.checkout(version_commit)
$version_commit = commit || repo.describe.split('-')[0]
puts "Using tag #{$version_commit}"
real_commit = repo.checkout($version_commit)
repo.update_bundle
if !semantic?(version_commit) || (semantic?(version_commit) && Gem::Version.create(version_commit) >= version4)
if !semantic?($version_commit) || (semantic?($version_commit) && Gem::Version.create($version_commit) >= version4)
references << PuppetReferences::Facter::FacterCli
elsif semantic?(version_commit) && Gem::Version.create(version_commit) < version4
elsif semantic?($version_commit) && Gem::Version.create($version_commit) < version4
reference = PuppetReferences::Facter::FacterCli.new(real_commit)
reference.build_v3_cli
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_references/facter/core_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def build_all
header_data = { title: 'Facter: Core Facts',
toc: 'columns',
canonical: "#{@latest}/core_facts.html", }
content = make_header(header_data) + PREAMBLE + raw_text
content = make_header(header_data, 'OpenFact', $version_commit) + PREAMBLE + raw_text # rubocop:disable Style/GlobalVars
filename = OUTPUT_DIR + 'core_facts.md'
filename.open('w') { |f| f.write(content) }
puts 'Core facts: done!'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_references/facter/facter_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def build_all
markdown_text, = Open3.capture3('mandoc -T markdown', stdin_data: raw_text)
# Strip the "TITLE - Manual" header line and the dated footer line mandoc adds
markdown_text = markdown_text.lines[1...-1].join
content = make_header(header_data) + markdown_text
content = make_header(header_data, 'OpenFact', $version_commit) + markdown_text # rubocop:disable Style/GlobalVars
filename = OUTPUT_DIR + 'cli.md'
filename.open('w') { |f| f.write(content) }
puts 'CLI documentation is done!'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_references/puppet/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def build_variant(filename, preferred_version = 'ruby4x')
# This substitution could potentially make things a bit brittle, but it has to be done because the jump
# From H2s to H4s is causing issues with the DITA-OT, which sees this as a rule violation. If it
# Does become an issue, we should return to this and figure out a better way to generate the functions doc.
content = make_header(header_data) + "\n\n" + PREAMBLE + "\n\n" + body.gsub(/#####\s(.*?:)/, '**\1**').gsub(
content = make_header(header_data, 'OpenVox', $version_commit) + "\n\n" + PREAMBLE + "\n\n" + body.gsub(/#####\s(.*?:)/, '**\1**').gsub( # rubocop:disable Style/GlobalVars
/####\s/, '###\s'
)
output_path = OUTPUT_DIR + filename
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_references/puppet/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def munge_and_copy_doc_file(file)
end
header_data = { title: "Puppet HTTP API: #{title}",
canonical: "#{@latest}/#{shortname}.html", }
content = make_header(header_data) + file.read
content = make_header(header_data, 'OpenVox', $version_commit) + file.read
dest = DOCS_DIR + file.basename
dest.open('w') { |f| f.write(content) }
end
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet_references/puppet/man.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def build_index(commands)
header_data = { title: 'Puppet Man Pages',
canonical: "#{@latest}/overview.html", }
index_text = <<~MSG
#{make_header(header_data)}
#{make_header(header_data, 'OpenVox', $version_commit)} # rubocop:disable Style/GlobalVars

Puppet's command line tools consist of a single `puppet` binary with many subcommands. The following subcommands are available in this version of Puppet:

Expand Down Expand Up @@ -124,7 +124,7 @@ def build_manpage(subcommand)
canonical: "#{@latest}/#{subcommand}.html", }
# raw_text = PuppetReferences::ManCommand.new(subcommand).get
man_filepath = PuppetReferences::PUPPET_DIR.to_s + "/man/man8/puppet-#{subcommand}.8"
content = make_header(header_data) + PuppetReferences::Util.convert_man(man_filepath)
content = make_header(header_data, 'OpenVox', $version_commit) + PuppetReferences::Util.convert_man(man_filepath) # rubocop:disable Style/GlobalVars
filename = OUTPUT_DIR + "#{subcommand}.md"
filename.open('w') { |f| f.write(content) }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_references/puppet/puppet_doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def build_reference(reference)
header_data = { title: "#{reference.capitalize} Reference",
toc: 'columns',
canonical: "#{@latest}/#{reference}.html", }
content = make_header(header_data) + raw_content
content = make_header(header_data, 'OpenVox', $version_commit) + raw_content # rubocop:disable Style/GlobalVars
filename = OUTPUT_DIR + "#{reference}.md"
filename.open('w') { |f| f.write(content) }
end
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet_references/puppet/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def build_index(names)
links = names.map do |name|
"* [#{name}](./#{name}.md)" unless skip_names.include?(name)
end
content = make_header(header_data) + "## List of resource types\n\n" + links.join("\n") + "\n\n" + PREAMBLE
content = make_header(header_data, 'OpenVox', $version_commit) + "## List of resource types\n\n" + links.join("\n") + "\n\n" + PREAMBLE # rubocop:disable Style/GlobalVars
filename = @output_dir_individual + 'overview.md'
filename.open('w') { |f| f.write(content) }
end
Expand All @@ -68,7 +68,7 @@ def build_unified_page(typedocs)
text_for_type(name, typedocs[name])
end.join("\n\n---------\n\n")

content = make_header(header_data) + "\n\n" + PREAMBLE + all_type_docs + "\n\n"
content = make_header(header_data, 'OpenVox', $version_commit) + "\n\n" + PREAMBLE + all_type_docs + "\n\n" # rubocop:disable Style/GlobalVars
filename = @output_dir_unified + "#{@base_filename}.md"
filename.open('w') { |f| f.write(content) }
end
Expand All @@ -83,7 +83,7 @@ def build_page(name, data)
puts "Type ref: Building #{name}"
header_data = { title: "Resource Type: #{name}",
canonical: "#{@latest}/types/#{name}.html", }
content = make_header(header_data) + "\n\n" + text_for_type(name, data) + "\n\n"
content = make_header(header_data, 'OpenVox', $version_commit) + "\n\n" + text_for_type(name, data) + "\n\n" # rubocop:disable Style/GlobalVars
filename = @output_dir_individual + "#{name}.md"
filename.open('w') { |f| f.write(content) }
end
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet_references/reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def initialize(commit)
@commit = commit
end

def make_header(header_data)
def make_header(header_data, source, commit)
default_header_data = { layout: 'default',
built_from_commit: @commit, }
PuppetReferences::Util.make_header(default_header_data.merge(header_data))
PuppetReferences::Util.make_header(default_header_data.merge(header_data), source, commit)
end
end
end
4 changes: 2 additions & 2 deletions lib/puppet_references/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
module PuppetReferences
module Util
# Given a hash of data, return YAML frontmatter suitable for the docs site.
def self.make_header(data)
def self.make_header(data, repo, commit)
# clean out any symbols:
generated_at = "> **NOTE:** This page was generated from the OpenVox source code on #{Time.now}"
generated_at = "> **NOTE:** This page was generated from the #{repo} source code based on version #{$version_commit} on #{Time.now}"
clean_data = data.transform_keys(&:to_s)
YAML.dump(clean_data) + "---\n\n" + "# #{clean_data['title']}" + "\n\n" + generated_at + "\n\n"
end
Expand Down
Loading