puppet-strings 2.1.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -4
  3. data/CONTRIBUTING.md +32 -2
  4. data/README.md +81 -17
  5. data/lib/puppet-strings.rb +13 -4
  6. data/lib/puppet-strings/describe.rb +68 -0
  7. data/lib/puppet-strings/json.rb +2 -38
  8. data/lib/puppet-strings/markdown.rb +3 -1
  9. data/lib/puppet-strings/markdown/base.rb +37 -16
  10. data/lib/puppet-strings/markdown/data_type.rb +34 -0
  11. data/lib/puppet-strings/markdown/data_types.rb +41 -0
  12. data/lib/puppet-strings/markdown/function.rb +2 -2
  13. data/lib/puppet-strings/markdown/resource_type.rb +19 -2
  14. data/lib/puppet-strings/markdown/table_of_contents.rb +1 -0
  15. data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +12 -4
  16. data/lib/puppet-strings/markdown/templates/data_type.erb +93 -0
  17. data/lib/puppet-strings/markdown/templates/data_type_function.erb +67 -0
  18. data/lib/puppet-strings/markdown/templates/function.erb +36 -1
  19. data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
  20. data/lib/puppet-strings/markdown/templates/resource_type.erb +32 -12
  21. data/lib/puppet-strings/markdown/templates/table_of_contents.erb +6 -6
  22. data/lib/puppet-strings/tasks/generate.rb +10 -3
  23. data/lib/puppet-strings/version.rb +1 -1
  24. data/lib/puppet-strings/yard.rb +16 -0
  25. data/lib/puppet-strings/yard/code_objects.rb +2 -0
  26. data/lib/puppet-strings/yard/code_objects/class.rb +2 -2
  27. data/lib/puppet-strings/yard/code_objects/data_type.rb +100 -0
  28. data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +58 -0
  29. data/lib/puppet-strings/yard/code_objects/defined_type.rb +2 -2
  30. data/lib/puppet-strings/yard/code_objects/function.rb +4 -4
  31. data/lib/puppet-strings/yard/code_objects/plan.rb +2 -2
  32. data/lib/puppet-strings/yard/code_objects/provider.rb +1 -1
  33. data/lib/puppet-strings/yard/code_objects/task.rb +1 -1
  34. data/lib/puppet-strings/yard/code_objects/type.rb +48 -6
  35. data/lib/puppet-strings/yard/handlers.rb +3 -0
  36. data/lib/puppet-strings/yard/handlers/puppet/data_type_alias_handler.rb +24 -0
  37. data/lib/puppet-strings/yard/handlers/ruby/base.rb +12 -1
  38. data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +393 -0
  39. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +2 -12
  40. data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +1 -9
  41. data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +3 -3
  42. data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +135 -0
  43. data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +56 -0
  44. data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +9 -115
  45. data/lib/puppet-strings/yard/parsers/json/parser.rb +4 -2
  46. data/lib/puppet-strings/yard/parsers/puppet/parser.rb +14 -7
  47. data/lib/puppet-strings/yard/parsers/puppet/statement.rb +25 -0
  48. data/lib/puppet-strings/yard/tags.rb +2 -0
  49. data/lib/puppet-strings/yard/tags/enum_tag.rb +12 -0
  50. data/lib/puppet-strings/yard/tags/factory.rb +16 -0
  51. data/lib/puppet-strings/yard/tags/overload_tag.rb +2 -2
  52. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_data_type.erb +10 -0
  53. data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +9 -0
  54. data/lib/puppet-strings/yard/templates/default/layout/html/objects.erb +2 -0
  55. data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +18 -1
  56. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/box_info.erb +10 -0
  57. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/header.erb +1 -0
  58. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/method_details_list.erb +6 -0
  59. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/note.erb +6 -0
  60. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/overview.erb +6 -0
  61. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +13 -0
  62. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/source.erb +12 -0
  63. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/summary.erb +4 -0
  64. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/todo.erb +6 -0
  65. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/alias_of.erb +10 -0
  66. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/box_info.erb +10 -0
  67. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/header.erb +1 -0
  68. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/note.erb +6 -0
  69. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/overview.erb +6 -0
  70. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb +17 -0
  71. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/source.erb +12 -0
  72. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/summary.erb +4 -0
  73. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/todo.erb +6 -0
  74. data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +3 -1
  75. data/lib/puppet-strings/yard/templates/default/tags/html/enum.erb +17 -0
  76. data/lib/puppet-strings/yard/templates/default/tags/setup.rb +7 -0
  77. data/lib/puppet-strings/yard/util.rb +48 -0
  78. data/lib/puppet/face/strings.rb +68 -3
  79. metadata +36 -45
  80. data/Gemfile +0 -37
  81. data/HISTORY.md +0 -218
  82. data/JSON.md +0 -802
  83. data/Rakefile +0 -93
  84. data/codecov.yml +0 -3
  85. data/misc/ANNOUNCEMENT_TEMPLATE.md +0 -40
  86. data/spec/acceptance/emit_json_options.rb +0 -71
  87. data/spec/acceptance/generate_markdown_spec.rb +0 -49
  88. data/spec/acceptance/lib/util.rb +0 -163
  89. data/spec/acceptance/running_strings_generate.rb +0 -54
  90. data/spec/fixtures/acceptance/modules/test/functions/add.pp +0 -9
  91. data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +0 -5
  92. data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +0 -2
  93. data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +0 -9
  94. data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +0 -15
  95. data/spec/fixtures/acceptance/modules/test/manifests/init.pp +0 -27
  96. data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +0 -27
  97. data/spec/fixtures/acceptance/modules/test/metadata.json +0 -6
  98. data/spec/fixtures/unit/json/output.json +0 -660
  99. data/spec/fixtures/unit/json/output_with_plan.json +0 -697
  100. data/spec/fixtures/unit/json/output_without_puppet_function.json +0 -480
  101. data/spec/fixtures/unit/markdown/output.md +0 -444
  102. data/spec/fixtures/unit/markdown/output_with_plan.md +0 -478
  103. data/spec/spec_helper.rb +0 -45
  104. data/spec/spec_helper_acceptance.rb +0 -28
  105. data/spec/unit/puppet-strings/json_spec.rb +0 -229
  106. data/spec/unit/puppet-strings/markdown/base_spec.rb +0 -146
  107. data/spec/unit/puppet-strings/markdown_spec.rb +0 -283
  108. data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +0 -92
  109. data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +0 -124
  110. data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +0 -217
  111. data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +0 -231
  112. data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +0 -315
  113. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +0 -729
  114. data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +0 -139
  115. data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +0 -214
  116. data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +0 -269
  117. data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +0 -70
  118. data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +0 -56
  119. data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +0 -209
  120. data/spec/unit/puppet-strings/yard/util_spec.rb +0 -48
@@ -5,6 +5,7 @@ module PuppetStrings::Markdown
5
5
  require_relative 'markdown/puppet_classes'
6
6
  require_relative 'markdown/functions'
7
7
  require_relative 'markdown/defined_types'
8
+ require_relative 'markdown/data_types'
8
9
  require_relative 'markdown/resource_types'
9
10
  require_relative 'markdown/puppet_tasks'
10
11
  require_relative 'markdown/puppet_plans'
@@ -13,13 +14,14 @@ module PuppetStrings::Markdown
13
14
  # generates markdown documentation
14
15
  # @return [String] markdown doc
15
16
  def self.generate
16
- final = "# Reference\n"
17
+ final = "# Reference\n\n"
17
18
  final << "<!-- DO NOT EDIT: This document was generated by Puppet Strings -->\n\n"
18
19
  final << PuppetStrings::Markdown::TableOfContents.render
19
20
  final << PuppetStrings::Markdown::PuppetClasses.render
20
21
  final << PuppetStrings::Markdown::DefinedTypes.render
21
22
  final << PuppetStrings::Markdown::ResourceTypes.render
22
23
  final << PuppetStrings::Markdown::Functions.render
24
+ final << PuppetStrings::Markdown::DataTypes.render
23
25
  final << PuppetStrings::Markdown::PuppetTasks.render
24
26
  final << PuppetStrings::Markdown::PuppetPlans.render
25
27
 
@@ -60,9 +60,9 @@ module PuppetStrings::Markdown
60
60
  :summary => 'summary',
61
61
  :note => 'note',
62
62
  :todo => 'todo' }.each do |method_name, tag_name|
63
- # @return [String] unless the tag is nil or the string.length == 0
63
+ # @return [String] unless the tag is nil or the string.empty?
64
64
  define_method method_name do
65
- @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text] unless @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0].nil? || @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text].length.zero?
65
+ @tags.find { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }[:text] if @tags.any? { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }
66
66
  end
67
67
  end
68
68
 
@@ -78,37 +78,42 @@ module PuppetStrings::Markdown
78
78
 
79
79
  # @return [String] data type of return value
80
80
  def return_type
81
- @tags.select { |tag| tag[:tag_name] == 'return' }[0][:types][0] unless @tags.select { |tag| tag[:tag_name] == 'return' }[0].nil?
81
+ @tags.find { |tag| tag[:tag_name] == 'return' }[:types][0] if @tags.any? { |tag| tag[:tag_name] == 'return' }
82
82
  end
83
83
 
84
84
  # @return [String] text from @since tag
85
85
  def since
86
- @tags.select { |tag| tag[:tag_name] == 'since' }[0][:text] unless @tags.select { |tag| tag[:tag_name] == 'since' }[0].nil?
86
+ @tags.find { |tag| tag[:tag_name] == 'since' }[:text] if @tags.any? { |tag| tag[:tag_name] == 'since' }
87
87
  end
88
88
 
89
89
  # @return [Array] @see tag hashes
90
90
  def see
91
- @tags.select { |tag| tag[:tag_name] == 'see' } unless @tags.select { |tag| tag[:tag_name] == 'see' }[0].nil?
91
+ select_tags('see')
92
92
  end
93
93
 
94
94
  # @return [Array] parameter tag hashes
95
95
  def params
96
- @tags.select { |tag| tag[:tag_name] == 'param' } unless @tags.select { |tag| tag[:tag_name] == 'param' }[0].nil?
96
+ select_tags('param')
97
97
  end
98
98
 
99
99
  # @return [Array] example tag hashes
100
100
  def examples
101
- @tags.select { |tag| tag[:tag_name] == 'example' } unless @tags.select { |tag| tag[:tag_name] == 'example' }[0].nil?
101
+ select_tags('example')
102
102
  end
103
103
 
104
104
  # @return [Array] raise tag hashes
105
105
  def raises
106
- @tags.select { |tag| tag[:tag_name] == 'raise' } unless @tags.select { |tag| tag[:tag_name] == 'raise' }[0].nil?
106
+ select_tags('raise')
107
107
  end
108
108
 
109
109
  # @return [Array] option tag hashes
110
110
  def options
111
- @tags.select { |tag| tag[:tag_name] == 'option' } unless @tags.select { |tag| tag[:tag_name] == 'option' }[0].nil?
111
+ select_tags('option')
112
+ end
113
+
114
+ # @return [Array] enum tag hashes
115
+ def enums
116
+ select_tags('enum')
112
117
  end
113
118
 
114
119
  # @param parameter_name
@@ -119,7 +124,15 @@ module PuppetStrings::Markdown
119
124
  opts_for_p unless opts_for_p.nil? || opts_for_p.length.zero?
120
125
  end
121
126
 
122
- # @return [Array] any defaults found for the component
127
+ # @param parameter_name
128
+ # parameter name to match to enum tags
129
+ # @return [Array] enum tag hashes that have a parent parameter_name
130
+ def enums_for_param(parameter_name)
131
+ enums_for_p = enums.select { |e| e[:parent] == parameter_name } unless enums.nil?
132
+ enums_for_p unless enums_for_p.nil? || enums_for_p.length.zero?
133
+ end
134
+
135
+ # @return [Hash] any defaults found for the component
123
136
  def defaults
124
137
  @registry[:defaults] unless @registry[:defaults].nil?
125
138
  end
@@ -153,12 +166,13 @@ module PuppetStrings::Markdown
153
166
  end
154
167
 
155
168
  def private?
156
- result = false
157
- api = @tags.find { |tag| tag[:tag_name] == 'api' }
158
- unless api.nil?
159
- result = api[:text] == 'private' ? true : false
160
- end
161
- result
169
+ @tags.any? { |tag| tag[:tag_name] == 'api' && tag[:text] == 'private' }
170
+ end
171
+
172
+ def word_wrap(text, line_width: 120, break_sequence: "\n")
173
+ text.split("\n").collect! do |line|
174
+ line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1#{break_sequence}").strip : line
175
+ end * break_sequence
162
176
  end
163
177
 
164
178
  # @return [String] full markdown rendering of a component
@@ -166,5 +180,12 @@ module PuppetStrings::Markdown
166
180
  file = File.join(File.dirname(__FILE__),"templates/#{template}")
167
181
  ERB.new(File.read(file), nil, '-').result(binding)
168
182
  end
183
+
184
+ private
185
+
186
+ def select_tags(name)
187
+ tags = @tags.select { |tag| tag[:tag_name] == name }
188
+ tags.empty? ? nil : tags
189
+ end
169
190
  end
170
191
  end
@@ -0,0 +1,34 @@
1
+ require 'puppet-strings/markdown/base'
2
+
3
+ module PuppetStrings::Markdown
4
+ # This class encapsualtes ruby data types and puppet type aliases
5
+ class DataType < Base
6
+ attr_reader :alias_of
7
+ attr_reader :functions
8
+
9
+ def initialize(registry)
10
+ @template = 'data_type.erb'
11
+ super(registry, 'data type')
12
+ @alias_of = registry[:alias_of] unless registry[:alias_of].nil?
13
+ @functions = @registry[:functions].nil? ? nil : @registry[:functions].map { |func| DataType::Function.new(func) }
14
+ end
15
+
16
+ def render
17
+ super(@template)
18
+ end
19
+ end
20
+
21
+ class DataType::Function < Base
22
+ def initialize(registry)
23
+ super(registry, 'data_type_function')
24
+ end
25
+
26
+ def render
27
+ super('data_type_function.erb')
28
+ end
29
+
30
+ def signature
31
+ @registry[:signature]
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'data_type'
2
+
3
+ module PuppetStrings::Markdown
4
+ module DataTypes
5
+
6
+ # @return [Array] list of data types
7
+ def self.in_dtypes
8
+ arr = YARD::Registry.all(:puppet_data_type).map!(&:to_hash)
9
+ arr.concat(YARD::Registry.all(:puppet_data_type_alias).map!(&:to_hash))
10
+
11
+ arr.sort! { |a,b| a[:name] <=> b[:name] }
12
+ arr.map! { |a| PuppetStrings::Markdown::DataType.new(a) }
13
+ end
14
+
15
+ def self.contains_private?
16
+ result = false
17
+ unless in_dtypes.nil?
18
+ in_dtypes.find { |type| type.private? }.nil? ? false : true
19
+ end
20
+ end
21
+
22
+ def self.render
23
+ final = in_dtypes.length > 0 ? "## Data types\n\n" : ""
24
+ in_dtypes.each do |type|
25
+ final << type.render unless type.private?
26
+ end
27
+ final
28
+ end
29
+
30
+
31
+ def self.toc_info
32
+ final = ["Data types"]
33
+
34
+ in_dtypes.each do |type|
35
+ final.push(type.toc_info)
36
+ end
37
+
38
+ final
39
+ end
40
+ end
41
+ end
@@ -30,11 +30,11 @@ module PuppetStrings::Markdown
30
30
  end
31
31
  end
32
32
 
33
- def error_type(r)
33
+ def error_type(r) # rubocop:disable Naming/UncommunicativeMethodParamName
34
34
  "`#{r.split(' ')[0]}`"
35
35
  end
36
36
 
37
- def error_text(r)
37
+ def error_text(r) # rubocop:disable Naming/UncommunicativeMethodParamName
38
38
  "#{r.split(' ').drop(1).join(' ')}"
39
39
  end
40
40
  end
@@ -12,11 +12,28 @@ module PuppetStrings::Markdown
12
12
  end
13
13
 
14
14
  def properties
15
- @registry[:properties]
15
+ return nil unless @registry[:properties]
16
+
17
+ @registry[:properties].sort_by { |p| p[:name] }
18
+ end
19
+
20
+ def checks
21
+ return nil unless @registry[:checks]
22
+
23
+ @registry[:checks].sort_by { |p| p[:name] }
24
+ end
25
+
26
+ # "checks" (such as "onlyif" or "creates") are another type of property
27
+ def properties_and_checks
28
+ return nil if properties.nil? && checks.nil?
29
+
30
+ ((properties || []) + (checks || [])).sort_by { |p| p[:name] }
16
31
  end
17
32
 
18
33
  def parameters
19
- @registry[:parameters]
34
+ return nil unless @registry[:parameters]
35
+
36
+ @registry[:parameters].sort_by { |p| p[:name] }
20
37
  end
21
38
 
22
39
  def regex_in_data_type?(data_type)
@@ -7,6 +7,7 @@ module PuppetStrings::Markdown
7
7
  PuppetStrings::Markdown::DefinedTypes,
8
8
  PuppetStrings::Markdown::ResourceTypes,
9
9
  PuppetStrings::Markdown::Functions,
10
+ PuppetStrings::Markdown::DataTypes,
10
11
  PuppetStrings::Markdown::PuppetTasks,
11
12
  PuppetStrings::Markdown::PuppetPlans].each do |r|
12
13
  toc = r.toc_info
@@ -1,4 +1,4 @@
1
- ### <%= name %>
1
+ ### `<%= name %>`
2
2
 
3
3
  <% if text -%>
4
4
  <%= text %>
@@ -24,10 +24,10 @@
24
24
  * **See also**
25
25
  <% see.each do |sa| -%>
26
26
  <% if sa[:name] -%>
27
- <%= sa[:name] %>
27
+ <%= " * #{sa[:name]}" %>
28
28
  <% end -%>
29
29
  <% if sa[:text] -%>
30
- <%= sa[:text] %>
30
+ <%= " * #{sa[:text]}" %>
31
31
  <% end -%>
32
32
  <% end -%>
33
33
 
@@ -65,9 +65,17 @@ Options:
65
65
  * **<%= o[:opt_name] %>** `<%= o[:opt_types][0] %>`: <%= o[:opt_text] %>
66
66
  <% end -%>
67
67
 
68
+ <% end -%>
69
+ <% if enums_for_param(param[:name]) -%>
70
+ Options:
71
+
72
+ <% enums_for_param(param[:name]).each do |e| -%>
73
+ * **<%= e[:opt_name] %>**: <%= e[:opt_text] %>
74
+ <% end -%>
75
+
68
76
  <% end -%>
69
77
  <% if defaults && defaults[param[:name]] -%>
70
- Default value: <%= value_string(defaults[param[:name]]) %>
78
+ Default value: `<%= value_string(defaults[param[:name]]) %>`
71
79
 
72
80
  <% end -%>
73
81
  <% end -%>
@@ -0,0 +1,93 @@
1
+ ### `<%= name %>`
2
+
3
+ <% if text -%>
4
+ <%= text %>
5
+ <% elsif summary -%>
6
+ <%= summary %>
7
+ <% else -%>
8
+ <%= "The #{name} data type." %>
9
+ <% end -%>
10
+
11
+ <% if todo -%>
12
+ * **TODO** <%= todo %>
13
+
14
+ <% end -%>
15
+ <% if note -%>
16
+ * **Note** <%= note %>
17
+
18
+ <% end -%>
19
+ <% if since -%>
20
+ * **Since** <%= since %>
21
+
22
+ <% end -%>
23
+ <% if see -%>
24
+ * **See also**
25
+ <% see.each do |sa| -%>
26
+ <% if sa[:name] -%>
27
+ <%= " * #{sa[:name]}" %>
28
+ <% end -%>
29
+ <% if sa[:text] -%>
30
+ <%= " * #{sa[:text]}" %>
31
+ <% end -%>
32
+ <% end -%>
33
+
34
+ <% end -%>
35
+ <% if examples -%>
36
+ #### Examples
37
+
38
+ <% examples.each do |eg| -%>
39
+ ##### <%= eg[:name] %>
40
+
41
+ ```puppet
42
+ <%= eg[:text] %>
43
+ ```
44
+
45
+ <% end -%>
46
+ <% end -%>
47
+ <% if alias_of -%>
48
+ Alias of `<%= alias_of %>`
49
+
50
+ <% end -%>
51
+ <% if params -%>
52
+ #### Parameters
53
+
54
+ The following parameters are available in the `<%= name %>` <%= @type %>.
55
+
56
+ <% params.each do |param| -%>
57
+ ##### `<%= param[:name] %>`
58
+
59
+ <% if param[:types] -%>
60
+ Data type: `<%= param[:types].join(', ') -%>`
61
+
62
+ <% end -%>
63
+ <%= param[:text] %>
64
+
65
+ <% if options_for_param(param[:name]) -%>
66
+ Options:
67
+
68
+ <% options_for_param(param[:name]).each do |o| -%>
69
+ * **<%= o[:opt_name] %>** `<%= o[:opt_types][0] %>`: <%= o[:opt_text] %>
70
+ <% end -%>
71
+
72
+ <% end -%>
73
+ <% if enums_for_param(param[:name]) -%>
74
+ Options:
75
+
76
+ <% enums_for_param(param[:name]).each do |e| -%>
77
+ * **<%= e[:opt_name] %>**: <%= e[:opt_text] %>
78
+ <% end -%>
79
+
80
+ <% end -%>
81
+ <% if defaults && defaults[param[:name]] -%>
82
+ Default value: `<%= value_string(defaults[param[:name]]) %>`
83
+
84
+ <% end -%>
85
+ <% end -%>
86
+ <% end -%>
87
+ <% if functions -%>
88
+ #### Functions
89
+
90
+ The following functions are available in the `<%= name %>` <%= @type %>.
91
+
92
+ <% functions.each do |func| -%><%= func.render -%><% end -%>
93
+ <% end -%>
@@ -0,0 +1,67 @@
1
+ ### `<%= name %>`
2
+
3
+ #### `<%= signature %>`
4
+
5
+ <% if text -%>
6
+ <%= text %>
7
+
8
+ <% elsif summary -%>
9
+ <%= summary %>
10
+
11
+ <% else -%>
12
+ <%= "The #{name} function." %>
13
+
14
+ <% end -%>
15
+ <% if note -%>
16
+ * **Note** <%= note %>
17
+
18
+ <% end -%>
19
+ <% if return_type -%>
20
+ Returns: `<%= return_type %>`<% if return_val %> <%= return_val %><% end %>
21
+
22
+ <% end -%>
23
+ <% if raises -%>
24
+ Raises:
25
+ <% raises.each do |r| -%>
26
+ * <%= error_type(r[:text]) %> <%= error_text(r[:text]) %>
27
+ <% end -%>
28
+
29
+ <% end -%>
30
+ <% if examples -%>
31
+ ##### Examples
32
+
33
+ <% examples.each do |eg| -%>
34
+ ###### <%= eg[:name] %>
35
+
36
+ ```puppet
37
+ <%= eg[:text] %>
38
+ ```
39
+
40
+ <% end -%>
41
+ <% end -%>
42
+ <% if params -%>
43
+ <% params.each do |param| -%>
44
+ ##### `<%= param[:name] %>`
45
+
46
+ Data type: `<%= param[:types][0] %>`
47
+
48
+ <%= param[:text] %>
49
+
50
+ <% if options_for_param(param[:name]) -%>
51
+ Options:
52
+
53
+ <% options_for_param(param[:name]).each do |o| -%>
54
+ * **<%= o[:opt_name] %>** `<%= o[:opt_types][0] %>`: <%= o[:opt_text] %>
55
+ <% end -%>
56
+
57
+ <% end -%>
58
+ <% if enums_for_param(param[:name]) -%>
59
+ Options:
60
+
61
+ <% enums_for_param(param[:name]).each do |e| -%>
62
+ * **<%= e[:opt_name] %>**: <%= e[:opt_text] %>
63
+ <% end -%>
64
+
65
+ <% end -%>
66
+ <% end -%>
67
+ <% end -%>