Skip to content

Commit b51072b

Browse files
authored
Merge pull request OpenVoxProject#146 from OpenVoxProject/add_information_on_autogenerate
Add information on autogenerate
2 parents 321304a + a1c6d31 commit b51072b

10 files changed

Lines changed: 27 additions & 23 deletions

File tree

lib/puppet_references.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
require 'pathname'
44

55
module PuppetReferences
6+
class << self
7+
attr_reader :version_commit
8+
end
9+
610
BASE_DIR = Pathname.new(File.expand_path(__FILE__)).parent.parent
711
PUPPET_DIR = BASE_DIR + 'vendor/openvox'
812
FACTER_DIR = BASE_DIR + 'vendor/openfact'
@@ -38,9 +42,9 @@ def self.build_puppet_references(commit)
3842
]
3943
config = PuppetReferences::Config.read
4044
repo = PuppetReferences::Repo.new('openvox', PUPPET_DIR, nil, config['puppet']['repo'])
41-
version_commit = commit || repo.describe.split('-')[0]
42-
puts "Using tag #{version_commit}"
43-
real_commit = repo.checkout(version_commit)
45+
@version_commit = commit || repo.describe.split('-')[0]
46+
puts "Using tag #{@version_commit}"
47+
real_commit = repo.checkout(@version_commit)
4448
repo.update_bundle
4549
build_from_list_of_classes(references, real_commit)
4650
end
@@ -57,13 +61,13 @@ def self.build_facter_references(commit)
5761
# we need the CLI docs for 3.y. We can remove this when we stop building 3.y.
5862
version4 = Gem::Version.create('4.0.0')
5963
repo = PuppetReferences::Repo.new('openfact', FACTER_DIR)
60-
version_commit = commit || repo.describe.split('-')[0]
61-
puts "Using tag #{version_commit}"
62-
real_commit = repo.checkout(version_commit)
64+
@version_commit = commit || repo.describe.split('-')[0]
65+
puts "Using tag #{@version_commit}"
66+
real_commit = repo.checkout(@version_commit)
6367
repo.update_bundle
64-
if !semantic?(version_commit) || (semantic?(version_commit) && Gem::Version.create(version_commit) >= version4)
68+
if !semantic?(@version_commit) || (semantic?(@version_commit) && Gem::Version.create(@version_commit) >= version4)
6569
references << PuppetReferences::Facter::FacterCli
66-
elsif semantic?(version_commit) && Gem::Version.create(version_commit) < version4
70+
elsif semantic?(@version_commit) && Gem::Version.create(@version_commit) < version4
6771
reference = PuppetReferences::Facter::FacterCli.new(real_commit)
6872
reference.build_v3_cli
6973
end

lib/puppet_references/facter/core_facts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def build_all
2020
header_data = { title: 'Facter: Core Facts',
2121
toc: 'columns',
2222
canonical: "#{@latest}/core_facts.html", }
23-
content = make_header(header_data) + PREAMBLE + raw_text
23+
content = make_header(header_data, 'OpenFact', PuppetReferences.version_commit) + PREAMBLE + raw_text
2424
filename = OUTPUT_DIR + 'core_facts.md'
2525
filename.open('w') { |f| f.write(content) }
2626
puts 'Core facts: done!'

lib/puppet_references/facter/facter_cli.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def build_all
3232
markdown_text, = Open3.capture3('mandoc -T markdown', stdin_data: raw_text)
3333
# Strip the "TITLE - Manual" header line and the dated footer line mandoc adds
3434
markdown_text = markdown_text.lines[1...-1].join
35-
content = make_header(header_data) + markdown_text
35+
content = make_header(header_data, 'OpenFact', PuppetReferences.version_commit) + markdown_text
3636
filename = OUTPUT_DIR + 'cli.md'
3737
filename.open('w') { |f| f.write(content) }
3838
puts 'CLI documentation is done!'
@@ -43,7 +43,7 @@ def build_v3_cli
4343
filename = OUTPUT_DIR + 'cli.md'
4444
man_filepath = PuppetReferences::FACTER_DIR + 'man/man8/facter.8'
4545
raw_text = PuppetReferences::Util.convert_man(man_filepath)
46-
content = make_header(header_data) + raw_text
46+
content = make_header(header_data, 'OpenFact', PuppetReferences.version_commit) + raw_text
4747
filename.open('w') { |f| f.write(content) }
4848
end
4949
end

lib/puppet_references/puppet/functions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def build_variant(filename, preferred_version = 'ruby4x')
4646
# This substitution could potentially make things a bit brittle, but it has to be done because the jump
4747
# From H2s to H4s is causing issues with the DITA-OT, which sees this as a rule violation. If it
4848
# Does become an issue, we should return to this and figure out a better way to generate the functions doc.
49-
content = make_header(header_data) + "\n\n" + PREAMBLE + "\n\n" + body.gsub(/#####\s(.*?:)/, '**\1**').gsub(
49+
content = make_header(header_data, 'OpenVox', PuppetReferences.version_commit) + "\n\n" + PREAMBLE + "\n\n" + body.gsub(/#####\s(.*?:)/, '**\1**').gsub(
5050
/####\s/, '###\s'
5151
)
5252
output_path = OUTPUT_DIR + filename

lib/puppet_references/puppet/http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def munge_and_copy_doc_file(file)
4747
end
4848
header_data = { title: "Puppet HTTP API: #{title}",
4949
canonical: "#{@latest}/#{shortname}.html", }
50-
content = make_header(header_data) + file.read
50+
content = make_header(header_data, 'OpenVox', PuppetReferences.version_commit) + file.read
5151
dest = DOCS_DIR + file.basename
5252
dest.open('w') { |f| f.write(content) }
5353
end

lib/puppet_references/puppet/man.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def build_index(commands)
7676
header_data = { title: 'Puppet Man Pages',
7777
canonical: "#{@latest}/overview.html", }
7878
index_text = <<~MSG
79-
#{make_header(header_data)}
79+
#{make_header(header_data, 'OpenVox', PuppetReferences.version_commit)}
8080
8181
Puppet's command line tools consist of a single `puppet` binary with many subcommands. The following subcommands are available in this version of Puppet:
8282
@@ -124,7 +124,7 @@ def build_manpage(subcommand)
124124
canonical: "#{@latest}/#{subcommand}.html", }
125125
# raw_text = PuppetReferences::ManCommand.new(subcommand).get
126126
man_filepath = PuppetReferences::PUPPET_DIR.to_s + "/man/man8/puppet-#{subcommand}.8"
127-
content = make_header(header_data) + PuppetReferences::Util.convert_man(man_filepath)
127+
content = make_header(header_data, 'OpenVox', PuppetReferences.version_commit) + PuppetReferences::Util.convert_man(man_filepath)
128128
filename = OUTPUT_DIR + "#{subcommand}.md"
129129
filename.open('w') { |f| f.write(content) }
130130
end

lib/puppet_references/puppet/puppet_doc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def build_reference(reference)
3030
header_data = { title: "#{reference.capitalize} Reference",
3131
toc: 'columns',
3232
canonical: "#{@latest}/#{reference}.html", }
33-
content = make_header(header_data) + raw_content
33+
content = make_header(header_data, 'OpenVox', PuppetReferences.version_commit) + raw_content
3434
filename = OUTPUT_DIR + "#{reference}.md"
3535
filename.open('w') { |f| f.write(content) }
3636
end

lib/puppet_references/puppet/type.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def build_index(names)
4646
links = names.map do |name|
4747
"* [#{name}](./#{name}.md)" unless skip_names.include?(name)
4848
end
49-
content = make_header(header_data) + "## List of resource types\n\n" + links.join("\n") + "\n\n" + PREAMBLE
49+
content = make_header(header_data, 'OpenVox', PuppetReferences.version_commit) + "## List of resource types\n\n" + links.join("\n") + "\n\n" + PREAMBLE
5050
filename = @output_dir_individual + 'overview.md'
5151
filename.open('w') { |f| f.write(content) }
5252
end
@@ -68,7 +68,7 @@ def build_unified_page(typedocs)
6868
text_for_type(name, typedocs[name])
6969
end.join("\n\n---------\n\n")
7070

71-
content = make_header(header_data) + "\n\n" + PREAMBLE + all_type_docs + "\n\n"
71+
content = make_header(header_data, 'OpenVox', PuppetReferences.version_commit) + "\n\n" + PREAMBLE + all_type_docs + "\n\n"
7272
filename = @output_dir_unified + "#{@base_filename}.md"
7373
filename.open('w') { |f| f.write(content) }
7474
end
@@ -83,7 +83,7 @@ def build_page(name, data)
8383
puts "Type ref: Building #{name}"
8484
header_data = { title: "Resource Type: #{name}",
8585
canonical: "#{@latest}/types/#{name}.html", }
86-
content = make_header(header_data) + "\n\n" + text_for_type(name, data) + "\n\n"
86+
content = make_header(header_data, 'OpenVox', PuppetReferences.version_commit) + "\n\n" + text_for_type(name, data) + "\n\n"
8787
filename = @output_dir_individual + "#{name}.md"
8888
filename.open('w') { |f| f.write(content) }
8989
end

lib/puppet_references/reference.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ def initialize(commit)
1010
@commit = commit
1111
end
1212

13-
def make_header(header_data)
13+
def make_header(header_data, source, commit)
1414
default_header_data = { layout: 'default',
1515
built_from_commit: @commit, }
16-
PuppetReferences::Util.make_header(default_header_data.merge(header_data))
16+
PuppetReferences::Util.make_header(default_header_data.merge(header_data), source, commit)
1717
end
1818
end
1919
end

lib/puppet_references/util.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
module PuppetReferences
77
module Util
88
# Given a hash of data, return YAML frontmatter suitable for the docs site.
9-
def self.make_header(data)
9+
def self.make_header(data, repo, commit)
1010
# clean out any symbols:
11-
generated_at = "> **NOTE:** This page was generated from the OpenVox source code on #{Time.now}"
11+
generated_at = "> **NOTE:** This page was generated from the #{repo} source code based on version #{commit} on #{Time.now}"
1212
clean_data = data.transform_keys(&:to_s)
1313
YAML.dump(clean_data) + "---\n\n" + "# #{clean_data['title']}" + "\n\n" + generated_at + "\n\n"
1414
end

0 commit comments

Comments
 (0)