puppet-strings 0.4.0 → 0.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +122 -0
  3. data/COMMITTERS.md +185 -0
  4. data/CONTRIBUTING.md +89 -0
  5. data/Gemfile +38 -0
  6. data/JSON.md +511 -0
  7. data/LICENSE +13 -0
  8. data/README.md +416 -0
  9. data/Rakefile +49 -0
  10. data/lib/puppet-strings.rb +63 -0
  11. data/lib/puppet-strings/json.rb +49 -0
  12. data/lib/puppet-strings/tasks.rb +10 -0
  13. data/lib/puppet-strings/tasks/generate.rb +23 -0
  14. data/lib/puppet-strings/tasks/gh_pages.rb +43 -0
  15. data/lib/puppet-strings/yard.rb +96 -0
  16. data/lib/puppet-strings/yard/code_objects.rb +8 -0
  17. data/lib/puppet-strings/yard/code_objects/base.rb +14 -0
  18. data/lib/puppet-strings/yard/code_objects/class.rb +59 -0
  19. data/lib/puppet-strings/yard/code_objects/defined_type.rb +58 -0
  20. data/lib/puppet-strings/yard/code_objects/function.rb +93 -0
  21. data/lib/puppet-strings/yard/code_objects/group.rb +30 -0
  22. data/lib/puppet-strings/yard/code_objects/provider.rb +93 -0
  23. data/lib/puppet-strings/yard/code_objects/type.rb +146 -0
  24. data/lib/puppet-strings/yard/handlers.rb +16 -0
  25. data/lib/puppet-strings/yard/handlers/puppet/base.rb +44 -0
  26. data/lib/puppet-strings/yard/handlers/puppet/class_handler.rb +23 -0
  27. data/lib/puppet-strings/yard/handlers/puppet/defined_type_handler.rb +23 -0
  28. data/lib/puppet-strings/yard/handlers/puppet/function_handler.rb +42 -0
  29. data/lib/puppet-strings/yard/handlers/ruby/base.rb +38 -0
  30. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +357 -0
  31. data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +113 -0
  32. data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +194 -0
  33. data/lib/puppet-strings/yard/parsers.rb +7 -0
  34. data/lib/puppet-strings/yard/parsers/puppet/parser.rb +70 -0
  35. data/lib/puppet-strings/yard/parsers/puppet/statement.rb +146 -0
  36. data/lib/puppet-strings/yard/tags.rb +6 -0
  37. data/lib/puppet-strings/yard/tags/overload_tag.rb +109 -0
  38. data/lib/puppet-strings/yard/tags/parameter_directive.rb +24 -0
  39. data/lib/puppet-strings/yard/tags/property_directive.rb +24 -0
  40. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_class.erb +9 -0
  41. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_defined_type.erb +9 -0
  42. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_function.erb +10 -0
  43. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_provider.erb +10 -0
  44. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_type.erb +9 -0
  45. data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +64 -0
  46. data/lib/puppet-strings/yard/templates/default/layout/html/objects.erb +35 -0
  47. data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +172 -0
  48. data/lib/puppet-strings/yard/templates/default/puppet_class/html/box_info.erb +26 -0
  49. data/lib/puppet-strings/yard/templates/default/puppet_class/html/header.erb +1 -0
  50. data/lib/puppet-strings/yard/templates/default/puppet_class/html/overview.erb +6 -0
  51. data/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb +14 -0
  52. data/lib/puppet-strings/yard/templates/default/puppet_class/html/source.erb +12 -0
  53. data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/box_info.erb +10 -0
  54. data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/header.erb +1 -0
  55. data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/overview.erb +6 -0
  56. data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb +5 -0
  57. data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/source.erb +12 -0
  58. data/lib/puppet-strings/yard/templates/default/puppet_function/html/box_info.erb +14 -0
  59. data/lib/puppet-strings/yard/templates/default/puppet_function/html/header.erb +1 -0
  60. data/lib/puppet-strings/yard/templates/default/puppet_function/html/overview.erb +18 -0
  61. data/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +5 -0
  62. data/lib/puppet-strings/yard/templates/default/puppet_function/html/source.erb +12 -0
  63. data/lib/puppet-strings/yard/templates/default/puppet_provider/html/box_info.erb +14 -0
  64. data/lib/puppet-strings/yard/templates/default/puppet_provider/html/collection.erb +10 -0
  65. data/lib/puppet-strings/yard/templates/default/puppet_provider/html/features.erb +12 -0
  66. data/lib/puppet-strings/yard/templates/default/puppet_provider/html/header.erb +1 -0
  67. data/lib/puppet-strings/yard/templates/default/puppet_provider/html/overview.erb +6 -0
  68. data/lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb +29 -0
  69. data/lib/puppet-strings/yard/templates/default/puppet_type/html/box_info.erb +20 -0
  70. data/lib/puppet-strings/yard/templates/default/puppet_type/html/features.erb +13 -0
  71. data/lib/puppet-strings/yard/templates/default/puppet_type/html/header.erb +1 -0
  72. data/lib/puppet-strings/yard/templates/default/puppet_type/html/overview.erb +6 -0
  73. data/lib/puppet-strings/yard/templates/default/puppet_type/html/parameters.erb +35 -0
  74. data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +32 -0
  75. data/lib/puppet-strings/yard/templates/default/tags/html/puppet_overload.erb +12 -0
  76. data/lib/puppet-strings/yard/templates/default/tags/setup.rb +15 -0
  77. data/lib/puppet/application/strings.rb +1 -0
  78. data/lib/puppet/face/strings.rb +80 -39
  79. data/spec/acceptance/emit_json_options.rb +41 -0
  80. data/spec/acceptance/lib/util.rb +15 -0
  81. data/spec/acceptance/running_strings_generate.rb +54 -0
  82. data/spec/fixtures/acceptance/modules/test/functions/add.pp +9 -0
  83. data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +5 -0
  84. data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +2 -0
  85. data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +9 -0
  86. data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +15 -0
  87. data/spec/fixtures/acceptance/modules/test/manifests/init.pp +27 -0
  88. data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +27 -0
  89. data/spec/fixtures/acceptance/modules/test/metadata.json +6 -0
  90. data/spec/fixtures/unit/json/output.json +348 -0
  91. data/spec/fixtures/unit/json/output_without_puppet_function.json +301 -0
  92. data/spec/spec_helper.rb +21 -0
  93. data/spec/spec_helper_acceptance.rb +27 -0
  94. data/spec/unit/puppet-strings/json_spec.rb +136 -0
  95. data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +155 -0
  96. data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +155 -0
  97. data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +169 -0
  98. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +613 -0
  99. data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +90 -0
  100. data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +214 -0
  101. data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +171 -0
  102. metadata +115 -92
  103. data/lib/puppet-strings/rake_tasks.rb +0 -18
  104. data/lib/puppet_x/puppetlabs/strings.rb +0 -64
  105. data/lib/puppet_x/puppetlabs/strings/actions.rb +0 -92
  106. data/lib/puppet_x/puppetlabs/strings/pops/yard_statement.rb +0 -79
  107. data/lib/puppet_x/puppetlabs/strings/pops/yard_transformer.rb +0 -47
  108. data/lib/puppet_x/puppetlabs/strings/util.rb +0 -65
  109. data/lib/puppet_x/puppetlabs/strings/yard/code_objects/defined_type_object.rb +0 -33
  110. data/lib/puppet_x/puppetlabs/strings/yard/code_objects/host_class_object.rb +0 -22
  111. data/lib/puppet_x/puppetlabs/strings/yard/code_objects/method_object.rb +0 -62
  112. data/lib/puppet_x/puppetlabs/strings/yard/code_objects/provider_object.rb +0 -24
  113. data/lib/puppet_x/puppetlabs/strings/yard/code_objects/puppet_namespace_object.rb +0 -48
  114. data/lib/puppet_x/puppetlabs/strings/yard/code_objects/type_object.rb +0 -42
  115. data/lib/puppet_x/puppetlabs/strings/yard/core_ext/yard.rb +0 -40
  116. data/lib/puppet_x/puppetlabs/strings/yard/handlers/base.rb +0 -13
  117. data/lib/puppet_x/puppetlabs/strings/yard/handlers/defined_type_handler.rb +0 -31
  118. data/lib/puppet_x/puppetlabs/strings/yard/handlers/heredoc_helper.rb +0 -80
  119. data/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb +0 -42
  120. data/lib/puppet_x/puppetlabs/strings/yard/handlers/provider_handler.rb +0 -95
  121. data/lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_3x_function_handler.rb +0 -54
  122. data/lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_4x_function_handler.rb +0 -234
  123. data/lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb +0 -295
  124. data/lib/puppet_x/puppetlabs/strings/yard/json_registry_store.rb +0 -85
  125. data/lib/puppet_x/puppetlabs/strings/yard/monkey_patches.rb +0 -68
  126. data/lib/puppet_x/puppetlabs/strings/yard/parser.rb +0 -30
  127. data/lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb +0 -9
  128. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/docstring.erb +0 -34
  129. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/header.erb +0 -5
  130. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/parameter_details.erb +0 -6
  131. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/setup.rb +0 -1
  132. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/setup.rb +0 -49
  133. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_class.erb +0 -2
  134. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_manifest.erb +0 -1
  135. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_plugin.erb +0 -21
  136. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_provider.erb +0 -1
  137. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_type.erb +0 -1
  138. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb +0 -82
  139. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/box_info.erb +0 -22
  140. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/setup.rb +0 -1
  141. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/subclasses.erb +0 -4
  142. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/setup.rb +0 -21
  143. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/html_helper.rb +0 -139
  144. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/layout/html/setup.rb +0 -18
  145. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/html/header.erb +0 -17
  146. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/setup.rb +0 -21
  147. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/text/header.erb +0 -2
  148. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/command_details.erb +0 -8
  149. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/confine_details.erb +0 -10
  150. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/default_details.erb +0 -10
  151. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/docstring.erb +0 -34
  152. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/feature_details.erb +0 -10
  153. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/header.erb +0 -5
  154. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/setup.rb +0 -1
  155. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/setup.rb +0 -50
  156. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/box_info.erb +0 -11
  157. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/header.erb +0 -5
  158. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/method_details_list.erb +0 -53
  159. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/method_summary.erb +0 -20
  160. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/setup.rb +0 -1
  161. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/setup.rb +0 -91
  162. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/template_helper.rb +0 -192
  163. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/docstring.erb +0 -34
  164. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/header.erb +0 -5
  165. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/parameter_details.erb +0 -12
  166. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/provider_details.erb +0 -10
  167. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/setup.rb +0 -1
  168. data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/setup.rb +0 -55
@@ -0,0 +1,10 @@
1
+ <div class="box_info">
2
+ <dl>
3
+ <dt>Defined in:</dt>
4
+ <dd>
5
+ <%= object.file %><% if object.files.size > 1 %><span class="defines">,<br />
6
+ <%= object.files[1..-1].map {|f| f.first }.join(",<br /> ") %></div>
7
+ <% end %>
8
+ </dd>
9
+ </dl>
10
+ </div>
@@ -0,0 +1 @@
1
+ <h1>Defined Type: <%= object.name %></h1>
@@ -0,0 +1,6 @@
1
+ <h2>Overview</h2>
2
+ <div class="docstring">
3
+ <div class="discussion">
4
+ <%= htmlify(object.docstring) %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,5 @@
1
+ # Initializes the template.
2
+ # @return [void]
3
+ def init
4
+ sections :header, :box_info, :overview, T('tags'), :source
5
+ end
@@ -0,0 +1,12 @@
1
+ <div class="method_details_list">
2
+ <table class="source_code">
3
+ <tr>
4
+ <td>
5
+ <pre class="lines"><%= "\n\n\n" %><%= h format_lines(object) %></pre>
6
+ </td>
7
+ <td>
8
+ <pre class="code"><span class="info file"># File '<%= h object.file %>'<% if object.line %>, line <%= object.line %><% end %></span><%= "\n\n" %><%= html_syntax_highlight object.source %></pre>
9
+ </td>
10
+ </tr>
11
+ </table>
12
+ </div>
@@ -0,0 +1,14 @@
1
+ <div class="box_info">
2
+ <dl>
3
+ <dt>Defined in:</dt>
4
+ <dd>
5
+ <%= object.file %><% if object.files.size > 1 %><span class="defines">,<br />
6
+ <%= object.files[1..-1].map {|f| f.first }.join(",<br /> ") %></div>
7
+ <% end %>
8
+ </dd>
9
+ </dl>
10
+ <dl>
11
+ <dt>Function type:</dt>
12
+ <dd><%= object.function_type %></dd>
13
+ </dl>
14
+ </div>
@@ -0,0 +1 @@
1
+ <h1>Puppet Function: <%= object.name %></h1>
@@ -0,0 +1,18 @@
1
+ <h2>Overview</h2>
2
+ <div class="method_details first">
3
+ <% unless object.has_tag? :overload %>
4
+ <div class="tags overload overload_item">
5
+ <span class="overload">
6
+ <span class="overload_item">
7
+ <span class="signature first" style="margin-left: 0px;"><%= "<strong>#{h(object.signature)}</strong> &#x21d2; #{signature_types(object, false)}" %></span>
8
+ </span>
9
+ </span>
10
+ </div>
11
+ <% end %>
12
+ <div class="docstring">
13
+ <div class="discussion">
14
+ <%= htmlify(object.docstring) %>
15
+ </div>
16
+ </div>
17
+ <%= yieldall %>
18
+ </div>
@@ -0,0 +1,5 @@
1
+ # Initializes the template.
2
+ # @return [void]
3
+ def init
4
+ sections :header, :box_info, :overview, [T('tags'), :source]
5
+ end
@@ -0,0 +1,12 @@
1
+ <div class="method_details_list">
2
+ <table class="source_code">
3
+ <tr>
4
+ <td>
5
+ <pre class="lines"><%= "\n\n\n" %><%= h format_lines(object) %></pre>
6
+ </td>
7
+ <td>
8
+ <pre class="code"><span class="info file"># File '<%= h object.file %>'<% if object.line %>, line <%= object.line %><% end %></span><%= "\n\n" %><%= html_syntax_highlight object.source %></pre>
9
+ </td>
10
+ </tr>
11
+ </table>
12
+ </div>
@@ -0,0 +1,14 @@
1
+ <div class="box_info">
2
+ <dl>
3
+ <dt>Defined in:</dt>
4
+ <dd>
5
+ <%= object.file %><% if object.files.size > 1 %><span class="defines">,<br />
6
+ <%= object.files[1..-1].map {|f| f.first }.join(",<br /> ") %></div>
7
+ <% end %>
8
+ </dd>
9
+ </dl>
10
+ <dl>
11
+ <dt>Resource type:</dt>
12
+ <dd><%= linkify(Registry["puppet_types::#{object.type_name}"], object.type_name) %></dd>
13
+ </dl>
14
+ </div>
@@ -0,0 +1,10 @@
1
+ <% if @collection && !@collection.empty? %>
2
+ <div class="tags">
3
+ <p class="tag_title"><%= @title %></p>
4
+ <ul>
5
+ <% @collection.each do |key, value| %>
6
+ <li><tt><%= key %> &mdash; <%= value %></tt></li>
7
+ <% end %>
8
+ </ul>
9
+ </div>
10
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% if object.features && !object.features.empty? %>
2
+ <div class="tags">
3
+ <p class="tag_title">Features</p>
4
+ <ul>
5
+ <% object.features.each do |feature| %>
6
+ <li>
7
+ <span class="name"><%= feature %></span>
8
+ </li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
@@ -0,0 +1 @@
1
+ <h1>Provider: <%= object.name %></h1>
@@ -0,0 +1,6 @@
1
+ <h2>Overview</h2>
2
+ <div class="docstring">
3
+ <div class="discussion">
4
+ <%= htmlify(object.docstring) %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,29 @@
1
+ # Initializes the template.
2
+ # @return [void]
3
+ def init
4
+ sections :header, :box_info, :overview, T('tags'), :features, :confines, :defaults, :commands
5
+ end
6
+
7
+ # Renders the confines section.
8
+ # @return [String] Returns the rendered section.
9
+ def confines
10
+ @title = 'Confines'
11
+ @collection = object.confines
12
+ erb(:collection)
13
+ end
14
+
15
+ # Renders the defaults section.
16
+ # @return [String] Returns the rendered section.
17
+ def defaults
18
+ @title = 'Default Provider For'
19
+ @collection = object.defaults
20
+ erb(:collection)
21
+ end
22
+
23
+ # Renders the commands section.
24
+ # @return [String] Returns the rendered section.
25
+ def commands
26
+ @title = 'Commands'
27
+ @collection = object.commands
28
+ erb(:collection)
29
+ end
@@ -0,0 +1,20 @@
1
+ <div class="box_info">
2
+ <dl>
3
+ <dt>Defined in:</dt>
4
+ <dd>
5
+ <%= object.file %><% if object.files.size > 1 %><span class="defines">,<br />
6
+ <%= object.files[1..-1].map {|f| f.first }.join(",<br /> ") %></div>
7
+ <% end %>
8
+ </dd>
9
+ </dl>
10
+ <% if @providers && !@providers.empty? %>
11
+ <dl>
12
+ <dt>Providers:</dt>
13
+ <dd>
14
+ <% @providers.each do |provider| %>
15
+ <%= linkify(provider, provider.name.to_s) %><br/>
16
+ <% end %>
17
+ </dd>
18
+ </dl>
19
+ <% end %>
20
+ </div>
@@ -0,0 +1,13 @@
1
+ <% if object.features && !object.features.empty? %>
2
+ <div class="tags">
3
+ <p class="tag_title">Features</p>
4
+ <ul>
5
+ <% object.features.each do |feature| %>
6
+ <li>
7
+ <span class="name"><%= feature.name %></span>
8
+ <% unless feature.docstring.empty? %> &mdash; <%= htmlify_line(feature.docstring) %><% end %>
9
+ </li>
10
+ <% end %>
11
+ </ul>
12
+ </div>
13
+ <% end %>
@@ -0,0 +1 @@
1
+ <h1>Resource Type: <%= object.name %></h1>
@@ -0,0 +1,6 @@
1
+ <h2>Overview</h2>
2
+ <div class="docstring">
3
+ <div class="discussion">
4
+ <%= htmlify(object.docstring) %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,35 @@
1
+ <% if @parameters && !@parameters.empty? %>
2
+ <div class="tags">
3
+ <p class="tag_title"><%= @tag_title %></p>
4
+ <ul>
5
+ <% @parameters.each do |parameter| %>
6
+ <li>
7
+ <span class="name"><%= parameter.name + (parameter.isnamevar ? ' (namevar)' : '') %></span>
8
+ <% if parameter.default %>
9
+ <span class="default"> (defaults to: <em><%= parameter.default %></em>)</span>
10
+ <% end %>
11
+ <% unless parameter.docstring.empty? %>
12
+ <div class="docstring">
13
+ <div class="discussion">
14
+ <%= htmlify(parameter.docstring) %>
15
+ </div>
16
+ </div>
17
+ <% end %>
18
+ <% unless parameter.values.empty? %>
19
+ <div>
20
+ Supported values:
21
+ <ul>
22
+ <% parameter.values.each do |value| %>
23
+ <li>
24
+ <% other = parameter.aliases[value] %>
25
+ <%= value %><% if other %> (alias for: <em><%= other %></em>)<% end %>
26
+ </li>
27
+ <% end %>
28
+ </ul>
29
+ </div>
30
+ <% end %>
31
+ </li>
32
+ <% end %>
33
+ </ul>
34
+ </div>
35
+ <% end %>
@@ -0,0 +1,32 @@
1
+ # Initializes the template.
2
+ # @return [void]
3
+ def init
4
+ sections :header, :box_info, :overview, T('tags'), :properties, :parameters, :features
5
+ end
6
+
7
+ # Renders the box_info section.
8
+ # @return [String] Returns the rendered section.
9
+ def box_info
10
+ @providers = PuppetStrings::Yard::CodeObjects::Providers.instance(object.name).children
11
+ erb(:box_info)
12
+ end
13
+
14
+ # Renders the properties section.
15
+ # @return [String] Returns the rendered section.
16
+ def properties
17
+ # Properties are the same thing as parameters (from the documentation standpoint),
18
+ # so reuse the same template but with a different title and data source.
19
+ @parameters = object.properties || []
20
+ @parameters.sort_by! { |p| p.name }
21
+ @tag_title = 'Properties'
22
+ erb(:parameters)
23
+ end
24
+
25
+ # Renders the parameters section.
26
+ # @return [String] Returns the rendered section.
27
+ def parameters
28
+ @parameters = object.parameters || []
29
+ @parameters.sort_by! { |p| p.name }
30
+ @tag_title = 'Parameters'
31
+ erb(:parameters)
32
+ end
@@ -0,0 +1,12 @@
1
+ <% if object.has_tag?(:overload) && object.tags(:overload).any? {|o| !o.docstring.blank? } %>
2
+ <p class="tag_title">Overloads:</p>
3
+ <ul class="overload">
4
+ <% object.tags(:overload).each_with_index do |overload, index| %>
5
+ <% next if overload.docstring.blank? %>
6
+ <li class="overload_item">
7
+ <span class="signature"><%= "<strong>#{h(overload.signature)}</strong> &#x21d2; #{signature_types(overload, false)}" %></span>
8
+ <%= yieldall :object => overload %>
9
+ </li>
10
+ <% end %>
11
+ </ul>
12
+ <% end %>
@@ -0,0 +1,15 @@
1
+ # Called to return parameter tags.
2
+ # @return [Array<YARD::Tag>] Returns the parameter tags if the object should have parameters.
3
+ def param
4
+ tag(:param) if
5
+ object.type == :method ||
6
+ object.type == :puppet_class ||
7
+ object.type == :puppet_defined_type ||
8
+ object.type == :puppet_function
9
+ end
10
+
11
+ # Renders the overload section.
12
+ # @return [String] Returns the rendered section.
13
+ def overload
14
+ erb(if object.type == :puppet_function then :puppet_overload else :overload end)
15
+ end
@@ -1,4 +1,5 @@
1
1
  require 'puppet/application/face_base'
2
2
 
3
+ # Implements the 'puppet strings' application.
3
4
  class Puppet::Application::Strings < Puppet::Application::FaceBase
4
5
  end
@@ -1,64 +1,105 @@
1
1
  require 'puppet/face'
2
- require 'puppet_x/puppetlabs/strings/yard/tags/directives'
3
2
 
3
+ # Implements the 'puppet strings' interface.
4
4
  Puppet::Face.define(:strings, '0.0.1') do
5
- summary "Generate Puppet documentation with YARD."
5
+ summary 'Generate Puppet documentation with YARD.'
6
6
 
7
- # Ensures that the user has the needed features to use puppet strings
8
- def check_required_features
9
- unless Puppet.features.yard?
10
- raise RuntimeError, "The 'yard' gem must be installed in order to use this face."
11
- end
7
+ action(:generate) do
8
+ default
12
9
 
13
- unless Puppet.features.rgen?
14
- raise RuntimeError, "The 'rgen' gem must be installed in order to use this face."
10
+ option '--emit-json-stdout' do
11
+ summary 'Print JSON representation of the documentation to stdout.'
15
12
  end
16
-
17
- if RUBY_VERSION.match(/^1\.8/)
18
- raise RuntimeError, "This face requires Ruby 1.9 or greater."
13
+ option '--emit-json FILE' do
14
+ summary 'Write JSON representation of the documentation to the given file.'
15
+ end
16
+ option '--markup FORMAT' do
17
+ summary "The markup format to use for docstring text (defaults to 'markdown')."
19
18
  end
20
- end
21
19
 
22
- action(:yardoc) do
23
- default
20
+ summary 'Generate documentation from files.'
21
+ arguments '[[search_pattern] ...]'
24
22
 
25
- option "--emit-json-stdout" do
26
- summary "Print json representation of the documentation to stdout"
23
+ when_invoked do |*args|
24
+ check_required_features
25
+ require 'puppet-strings'
26
+
27
+ PuppetStrings::generate(
28
+ args.count > 1 ? args[0..-2] : PuppetStrings::DEFAULT_SEARCH_PATTERNS,
29
+ build_generate_options(args.last)
30
+ )
31
+ nil
27
32
  end
28
- option "--emit-json FILE" do
29
- summary "Write json representation of the documentation to FILE"
33
+ end
34
+
35
+ action(:server) do
36
+ option '--markup FORMAT' do
37
+ summary "The markup format to use for docstring text (defaults to 'markdown')."
30
38
  end
31
39
 
32
- summary "Generate YARD documentation from files."
33
- arguments "[manifest_file.pp ...]"
40
+ summary 'Runs a local documentation server for the modules in the current Puppet environment.'
41
+ arguments '[[module_name] ...]'
34
42
 
35
43
  when_invoked do |*args|
36
44
  check_required_features
37
- require 'puppet_x/puppetlabs/strings/util'
45
+ require 'puppet-strings'
46
+
47
+ modules = args.count > 1 ? args[0..-2] : []
38
48
 
39
- PuppetX::PuppetLabs::Strings::Util.generate(args)
49
+ # Generate documentation for all (or the given) modules
50
+ module_docs = []
51
+ environment = Puppet.lookup(:current_environment)
52
+ environment.modules.each do |mod|
53
+ next unless modules.empty? || modules.include?(mod.name)
54
+ db = File.join(mod.path, '.yardoc')
55
+ patterns = PuppetStrings::DEFAULT_SEARCH_PATTERNS.map do |p|
56
+ File.join(mod.path, p)
57
+ end
58
+ puts "Generating documentation for Puppet module '#{mod.name}'."
59
+ PuppetStrings.generate(patterns, build_generate_options(args.last, '--db', db))
40
60
 
41
- # Puppet prints the return value of the action. The return value of this
42
- # action is that of the yardoc_actions invocation, which is the boolean
43
- # "true". This clutters the statistics yard prints, so instead return the
44
- # empty string. Note an extra newline will also be printed.
45
- ""
61
+ # Clear the registry so that the next call to generate has a clean database
62
+ YARD::Registry.clear
63
+
64
+ module_docs << mod.name
65
+ module_docs << db
66
+ end
67
+
68
+ if module_docs.empty?
69
+ puts 'No Puppet modules were found to serve documentation for.'
70
+ return
71
+ end
72
+ puts 'Starting YARD documentation server.'
73
+ PuppetStrings::run_server('-m', *module_docs)
74
+ nil
46
75
  end
47
76
  end
48
77
 
49
- # NOTE: Modeled after the `yard gems` command which builds doc indicies
50
- # (.yardoc directories) for Ruby Gems. Currently lacks the fine-grained
51
- # control over where these indicies are created and just dumps them in the
52
- # module roots.
53
-
54
- action(:server) do
55
- summary "Serve YARD documentation for modules."
78
+ # Checks that the required features are installed.
79
+ # @return [void]
80
+ def check_required_features
81
+ raise RuntimeError, "The 'yard' gem must be installed in order to use this face." unless Puppet.features.yard?
82
+ raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." unless Puppet.features.rgen?
83
+ raise RuntimeError, 'This face requires Ruby 1.9 or greater.' if RUBY_VERSION =~ /^1\.8/
84
+ end
56
85
 
57
- when_invoked do |*args|
58
- check_required_features
59
- require 'puppet_x/puppetlabs/strings/util'
86
+ # Builds the options to PuppetStrings.generate.
87
+ # @param [Hash] options The Puppet face options hash.
88
+ # @param [Array] yard_args The additional arguments to pass to YARD.
89
+ # @return [Hash] Returns the PuppetStrings.generate options hash.
90
+ def build_generate_options(options = nil, *yard_args)
91
+ generate_options = {}
92
+ generate_options[:debug] = Puppet[:debug]
93
+ generate_options[:backtrace] = Puppet[:trace]
94
+ generate_options[:yard_args] = yard_args unless yard_args.empty?
60
95
 
61
- PuppetX::PuppetLabs::Strings::Util.serve(args)
96
+ if options
97
+ markup = options[:markup]
98
+ generate_options[:markup] = markup if markup
99
+ json_file = options[:emit_json]
100
+ generate_options[:json] = json_file if json_file
101
+ generate_options[:json] = nil if options[:emit_json_stdout]
62
102
  end
103
+ generate_options
63
104
  end
64
105
  end