Skip to content

Commit 1a9c881

Browse files
committed
(PUP-12057) Generate one resource type per page
This generates one page per resource type in references/types/*.md similar to what was done in puppet-docs.
1 parent 3343f91 commit 1a9c881

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

rakelib/generate_references.rake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ TYPES_OVERVIEW_ERB = File.join(__dir__, 'references/types/overview.erb')
2020
TYPES_OVERVIEW_MD = File.join(TYPES_DIR, 'overview.md')
2121
UNIFIED_TYPE_ERB = File.join(__dir__, 'references/unified_type.erb')
2222
UNIFIED_TYPE_MD = File.join(OUTPUT_DIR, 'type.md')
23+
SINGLE_TYPE_ERB = File.join(__dir__, 'references/types/single_type.erb')
2324

2425
def render_erb(erb_file, variables)
2526
# Create a binding so only the variables we specify will be visible
@@ -332,6 +333,7 @@ namespace :references do
332333
end
333334
end
334335

336+
desc "Generate resource type references"
335337
task :type do
336338
FileUtils.mkdir_p(TYPES_DIR)
337339

@@ -385,6 +387,24 @@ namespace :references do
385387
content = render_erb(UNIFIED_TYPE_ERB, variables)
386388
File.write(UNIFIED_TYPE_MD, content)
387389
puts "Generated #{UNIFIED_TYPE_MD}"
390+
391+
# Based on https://github.com/puppetlabs/puppet-docs/blob/1a13be3fc6981baa8a96ff832ab090abc986830e/lib/puppet_references/puppet/type.rb#L78-L85
392+
# one type per page
393+
types.each do |type|
394+
variables = {
395+
title: "Resource Type: #{type}",
396+
type: type,
397+
sha: sha,
398+
now: now,
399+
canonical: "/puppet/latest/types/#{type}.html",
400+
body: render_resource_type(type, type_data[type])
401+
}
402+
403+
content = render_erb(SINGLE_TYPE_ERB, variables)
404+
output = File.join(TYPES_DIR, "#{type}.md")
405+
File.write(output, content)
406+
puts "Generated #{output}"
407+
end
388408
end
389409
end
390410
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
layout: default
3+
built_from_commit: <%= sha %>
4+
title: '<%= title %>'
5+
canonical: "/puppet/latest/types/<%= type %>.html"
6+
---
7+
8+
# <%= title %>
9+
10+
> **NOTE:** This page was generated from the Puppet source code on <%= now %>
11+
12+
13+
14+
<%= body %>
15+

0 commit comments

Comments
 (0)