Skip to content

Commit 2b65df7

Browse files
author
Heston Hoffman
authored
Merge pull request #1070 from puppetlabs/migrate-generated-docs
Migrate generated docs
2 parents e69e2f5 + c454c3a commit 2b65df7

File tree

12 files changed

+46
-53
lines changed

12 files changed

+46
-53
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ group(:build_site) do
1616
end
1717

1818
group(:generate_references) do
19-
gem 'ronn', '~> 0.7'
2019
gem 'yard', '~> 0.9'
2120
gem 'rdoc', '~> 6.2'
2221
gem 'rgen', '~> 0.8'

Gemfile.lock

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ GEM
3838
rchardet (~> 1.8)
3939
hiera (3.7.0)
4040
hocon (1.3.1)
41-
hpricot (0.8.6)
4241
http_parser.rb (0.6.0)
4342
httpclient (2.8.3)
4443
i18n (1.8.10)
@@ -77,7 +76,6 @@ GEM
7776
mini_portile2 (2.5.0)
7877
minitest (5.14.4)
7978
multi_json (1.15.0)
80-
mustache (1.1.1)
8179
nokogiri (1.11.3)
8280
mini_portile2 (~> 2.5.0)
8381
racc (~> 1.4)
@@ -129,14 +127,9 @@ GEM
129127
rb-inotify (0.10.1)
130128
ffi (~> 1.0)
131129
rchardet (1.8.0)
132-
rdiscount (2.2.0.2)
133130
rdoc (6.3.0)
134131
rexml (3.2.5)
135132
rgen (0.8.2)
136-
ronn (0.7.3)
137-
hpricot (>= 0.8.2)
138-
mustache (>= 0.7.0)
139-
rdiscount (>= 1.5.8)
140133
rouge (3.26.0)
141134
safe_yaml (1.0.5)
142135
sassc (2.4.0)
@@ -182,8 +175,10 @@ DEPENDENCIES
182175
rake (~> 13.0, >= 13.0.1)
183176
rdoc (~> 6.2)
184177
rgen (~> 0.8)
185-
ronn (~> 0.7)
186178
versionomy (~> 0.5.0)
187179
vlad (~> 2.7)
188180
vlad-git (~> 2.1)
189181
yard (~> 0.9)
182+
183+
BUNDLED WITH
184+
2.2.14

lib/puppet_references.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@ def self.build_puppet_references(commit)
4343
build_from_list_of_classes(references, real_commit)
4444
end
4545

46+
def self.is_semantic?(string)
47+
Gem::Version.correct?(string)
48+
end
49+
4650
def self.build_facter_references(commit)
4751
references = [
48-
PuppetReferences::Facter::CoreFacts,
49-
PuppetReferences::Facter::FacterCli
52+
PuppetReferences::Facter::CoreFacts
5053
]
54+
# Adding this workaround so the build doesn't fail for 3.y. Check with Claire to see if
55+
# we need the CLI docs for 3.y. We can remove this when we stop building 3.y.
56+
version_4 = Gem::Version.create('4.0.0')
57+
references << PuppetReferences::Facter::FacterCli if !is_semantic?(commit) || !is_semantic?(commit) && Gem::Version.create(commit) >= version_4
5158
repo = PuppetReferences::Repo.new('facter', FACTER_DIR)
5259
real_commit = repo.checkout(commit)
5360
build_from_list_of_classes(references, real_commit)

lib/puppet_references/facter/core_facts_preamble.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
This is a list of all of the built-in facts that ship with Facter, which includes both legacy facts and newer structured facts.
22

3-
Not all of them apply to every system, and your site might also use [custom facts](./custom_facts.html) delivered via Puppet modules. To see the full list of structured facts and values on a given system (including plugin facts), run `puppet facts` at the command line. If you are using Puppet Enterprise, you can view all of the facts for any node on the node's page in the console.
3+
Not all of them apply to every system, and your site might also use [custom facts](custom_facts.dita) delivered via Puppet modules. To see the full list of structured facts and values on a given system (including plugin facts), run `puppet facts` at the command line. If you are using Puppet Enterprise, you can view all of the facts for any node on the node's page in the console.
44

5-
You can access facts in your Puppet manifests as `$fact_name` or `$facts[fact_name]`. For more information, see [the Puppet docs on facts and built-in variables.]({{puppet}}/lang_facts_and_builtin_vars.html)
5+
You can access facts in your Puppet manifests as `$fact_name` or `$facts[fact_name]`. For more information, see [the Puppet docs on facts and built-in variables.](lang_facts_and_builtin_vars.dita)
66

77
> **Legacy Facts Note:** As of Facter 3, legacy facts such as `architecture` are hidden by default to reduce noise in Facter's default command-line output. These older facts are now part of more useful structured facts; for example, `architecture` is now part of the `os` fact and accessible as `os.architecture`. You can still use these legacy facts in Puppet manifests (`$architecture`), request them on the command line (`facter architecture`), and view them alongside structured facts (`facter --show-legacy`).
88
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# Facter CLI
21

32
---

lib/puppet_references/puppet/functions.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def build_variant(filename, preferred_version = 'ruby4x')
2626
puts "Functions ref (#{filename}): Building"
2727
strings_data = PuppetReferences::Puppet::Strings.new
2828
functions = strings_data['puppet_functions']
29-
generated_at = "> **NOTE:** This page was generated from the Puppet source code on #{Time.now.to_s}"
3029
header_data = {title: 'Built-in function reference',
3130
canonical: "#{@latest}/function.html",
3231
toc_levels: 2,
@@ -46,12 +45,14 @@ def build_variant(filename, preferred_version = 'ruby4x')
4645
template_binding = OpenStruct.new({ functions: functions }).instance_eval {binding}
4746

4847
body = ERB.new(File.read(TEMPLATE_FILE), nil, '-').result(template_binding)
49-
content = make_header(header_data) + generated_at + "\n\n" + PREAMBLE + "\n\n" + body + generated_at
48+
# This substitution could potentially make things a bit brittle, but it has to be done because the jump
49+
# From H2s to H4s is causing issues with the DITA-OT, which sees this as a rule violation. If it
50+
# Does become an issue, we should return to this and figure out a better way to generate the functions doc.
51+
content = make_header(header_data) + "\n\n" + PREAMBLE + "\n\n" + body.gsub(/#####\s(.*?:)/,'**\1**').gsub(/####\s/,'###\s')
5052
output_path = OUTPUT_DIR + filename
5153
output_path.open('w') {|f| f.write(content)}
5254
puts "Functions ref (#{filename}): Done!"
5355
end
5456
end
5557
end
5658
end
57-

lib/puppet_references/puppet/functions_preamble.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
This page is a list of Puppet's built-in functions, with descriptions of what they do and how to use them.
22

3-
Functions are plugins you can call during catalog compilation. A call to any function is an expression that resolves to a value. For more information on how to call functions, see [the language reference page about function calls.](./lang_functions.html)
3+
Functions are plugins you can call during catalog compilation. A call to any function is an expression that resolves to a value. For more information on how to call functions, see [the language reference page about function calls.](lang_functions.dita)
44

5-
Many of these function descriptions include auto-detected _signatures,_ which are short reminders of the function's allowed arguments. These signatures aren't identical to the syntax you use to call the function; instead, they resemble a parameter list from a Puppet [class](./lang_classes.html), [defined resource type](./lang_defined_types.html), [function](./lang_write_functions_in_puppet.html), or [lambda](./lang_lambdas.html). The syntax of a signature is:
5+
Many of these function descriptions include auto-detected _signatures,_ which are short reminders of the function's allowed arguments. These signatures aren't identical to the syntax you use to call the function; instead, they resemble a parameter list from a Puppet [class](lang_classes.dita), [defined resource type](lang_defined_types.dita), [function](lang_write_functions_in_puppet.dita), or [lambda](lang_lambdas.dita). The syntax of a signature is:
66

77
```
88
<FUNCTION NAME>(<DATA TYPE> <ARGUMENT NAME>, ...)
99
```
1010

11-
The `<DATA TYPE>` is a [Puppet data type value](./lang_data_type.html), like `String` or `Optional[Array[String]]`. The `<ARGUMENT NAME>` is a descriptive name chosen by the function's author to indicate what the argument is used for.
11+
The `<DATA TYPE>` is a [Puppet data type value](lang_data_type.dita), like `String` or `Optional[Array[String]]`. The `<ARGUMENT NAME>` is a descriptive name chosen by the function's author to indicate what the argument is used for.
1212

1313
* Any arguments with an `Optional` data type can be omitted from the function call.
1414
* Arguments that start with an asterisk (like `*$values`) can be repeated any number of times.
15-
* Arguments that start with an ampersand (like `&$block`) aren't normal arguments; they represent a code block, provided with [Puppet's lambda syntax.](./lang_lambdas.html)
15+
* Arguments that start with an ampersand (like `&$block`) aren't normal arguments; they represent a code block, provided with [Puppet's lambda syntax.](lang_lambdas.dita)
1616

1717
## `undef` values in Puppet 6
1818

lib/puppet_references/puppet/functions_template.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Signature <%= index+1 %>
1616
<% has_parameters = signature['docstring']['tags'].detect {|tag| tag['tag_name'] == 'param' && tag['text'] != '' && tag['text'] != nil }
1717
if has_parameters -%>
1818

19-
#### Parameters
19+
### Parameters
2020

2121
<% signature['docstring']['tags'].select {|tag| tag['tag_name'] == 'param' && tag['text'] != '' && tag['text'] != nil}.each do |param| -%>
2222

@@ -31,7 +31,7 @@ Return type(s): <%= return_types['types'].map {|t| "`#{t}`"}.join(', ') %>. <%=
3131
has_examples = signature['docstring']['tags'].detect {|tag| tag['tag_name'] == 'example' && tag['text'] != '' && tag['text'] != nil }
3232
if has_examples %>
3333

34-
#### Examples
34+
### Examples
3535

3636
<% signature['docstring']['tags'].select {|tag| tag['tag_name'] == 'example' && tag['text'] != '' && tag['text'] != nil}.each do |example| -%>
3737
<%= example['name'] %>

lib/puppet_references/puppet/man.rb

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'puppet_references'
2+
23
module PuppetReferences
34
module Puppet
45
class Man < PuppetReferences::Reference
@@ -82,7 +83,7 @@ def build_index(commands)
8283
8384
These subcommands form the core of Puppet's tool set, and every user should understand what they do.
8485
85-
#{ categories[:core].reduce('') {|memo, item| memo << "- [puppet #{item}](./#{item}.html)\n"} }
86+
#{ categories[:core].reduce('') {|memo, item| memo << "- [puppet #{item}](#{item}.md)\n"} }
8687
8788
> Note: The `puppet cert` command is available only in Puppet versions prior to 6.0. For 6.0 and later, use the [`puppetserver cert`command](https://puppet.com/docs/puppet/6.0/puppet_server_ca_cli.html).
8889
@@ -91,14 +92,14 @@ def build_index(commands)
9192
9293
Many or most users need to use these subcommands at some point, but they aren't needed for daily use the way the core tools are.
9394
94-
#{ categories[:occasional].reduce('') {|memo, item| memo << "- [puppet #{item}](./#{item}.html)\n"} }
95+
#{ categories[:occasional].reduce('') {|memo, item| memo << "- [puppet #{item}](#{item}.md)\n"} }
9596
9697
Niche subcommands
9798
-----
9899
99100
Most users can ignore these subcommands. They're only useful for certain niche workflows, and most of them are interfaces to Puppet's internal subsystems.
100101
101-
#{ categories[:weird].reduce('') {|memo, item| memo << "- [puppet #{item}](./#{item}.html)\n"} }
102+
#{ categories[:weird].reduce('') {|memo, item| memo << "- [puppet #{item}](#{item}.md)\n"} }
102103
103104
EOT
104105
# write index
@@ -114,24 +115,16 @@ def get_subcommands
114115
applications
115116
end
116117

117-
def render_with_ronn(raw_text)
118-
rendered_html = ''
119-
Dir.chdir(PuppetReferences::BASE_DIR) do
120-
ronn = IO.popen("bundle exec ronn --pipe -f", "r+")
121-
ronn.write(raw_text)
122-
ronn.close_write
123-
rendered_html = ronn.read
124-
ronn.close
125-
end
126-
rendered_html
118+
def code_wrap(raw_text)
119+
"<pre><code>" + raw_text.gsub('<','❮').gsub('>','❯') + "</code></pre>"
127120
end
128121

129122
def build_manpage(subcommand)
130123
puts "Man pages: Building #{subcommand}"
131124
header_data = {title: "Man Page: puppet #{subcommand}",
132125
canonical: "#{@latest}/#{subcommand}.html"}
133126
raw_text = PuppetReferences::ManCommand.new(subcommand).get
134-
content = make_header(header_data) + render_with_ronn(raw_text)
127+
content = make_header(header_data) + code_wrap(raw_text)
135128
filename = OUTPUT_DIR + "#{subcommand}.md"
136129
filename.open('w') {|f| f.write(content)}
137130
end

lib/puppet_references/puppet/type.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def build_all
3838

3939
def build_index(names)
4040
header_data = {title: 'Resource Types: Index',
41-
canonical: "#{@latest}/types/index.html"}
41+
canonical: "#{@latest}/types/index.md"}
4242
links = names.map {|name|
43-
"* [#{name}](./#{name}.html)"
43+
"* [#{name}](./#{name}.md)" unless name == 'component' || name == 'whit'
4444
}
4545
content = make_header(header_data) + "## List of Resource Types\n\n" + links.join("\n") + "\n\n" + PREAMBLE
4646
filename = @output_dir_individual + 'index.md'
@@ -58,14 +58,13 @@ def build_unified_page(typedocs)
5858
canonical: "#{@latest}/type.html",
5959
toc_levels: 2,
6060
toc: 'columns'}
61-
generated_at = "> **NOTE:** This page was generated from the Puppet source code on #{Time.now.to_s}"
6261

6362
sorted_type_list = typedocs.keys.sort
6463
all_type_docs = sorted_type_list.collect{|name|
6564
text_for_type(name, typedocs[name])
6665
}.join("\n\n---------\n\n")
6766

68-
content = make_header(header_data) + generated_at + "\n\n" + PREAMBLE + all_type_docs + "\n\n" + generated_at
67+
content = make_header(header_data) + "\n\n" + PREAMBLE + all_type_docs + "\n\n"
6968
filename = @output_dir_unified + "#{@base_filename}.md"
7069
filename.open('w') {|f| f.write(content)}
7170
end
@@ -80,8 +79,7 @@ def build_page(name, data)
8079
puts "Type ref: Building #{name}"
8180
header_data = {title: "Resource Type: #{name}",
8281
canonical: "#{@latest}/types/#{name}.html"}
83-
generated_at = "> **NOTE:** This page was generated from the Puppet source code on #{Time.now.to_s}"
84-
content = make_header(header_data) + generated_at + "\n\n" + text_for_type(name, data) + "\n\n" + generated_at
82+
content = make_header(header_data) + "\n\n" + text_for_type(name, data) + "\n\n"
8583
filename = @output_dir_individual + "#{name}.md"
8684
filename.open('w') {|f| f.write(content)}
8785
end

0 commit comments

Comments
 (0)