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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +122 -0
- data/COMMITTERS.md +185 -0
- data/CONTRIBUTING.md +89 -0
- data/Gemfile +38 -0
- data/JSON.md +511 -0
- data/LICENSE +13 -0
- data/README.md +416 -0
- data/Rakefile +49 -0
- data/lib/puppet-strings.rb +63 -0
- data/lib/puppet-strings/json.rb +49 -0
- data/lib/puppet-strings/tasks.rb +10 -0
- data/lib/puppet-strings/tasks/generate.rb +23 -0
- data/lib/puppet-strings/tasks/gh_pages.rb +43 -0
- data/lib/puppet-strings/yard.rb +96 -0
- data/lib/puppet-strings/yard/code_objects.rb +8 -0
- data/lib/puppet-strings/yard/code_objects/base.rb +14 -0
- data/lib/puppet-strings/yard/code_objects/class.rb +59 -0
- data/lib/puppet-strings/yard/code_objects/defined_type.rb +58 -0
- data/lib/puppet-strings/yard/code_objects/function.rb +93 -0
- data/lib/puppet-strings/yard/code_objects/group.rb +30 -0
- data/lib/puppet-strings/yard/code_objects/provider.rb +93 -0
- data/lib/puppet-strings/yard/code_objects/type.rb +146 -0
- data/lib/puppet-strings/yard/handlers.rb +16 -0
- data/lib/puppet-strings/yard/handlers/puppet/base.rb +44 -0
- data/lib/puppet-strings/yard/handlers/puppet/class_handler.rb +23 -0
- data/lib/puppet-strings/yard/handlers/puppet/defined_type_handler.rb +23 -0
- data/lib/puppet-strings/yard/handlers/puppet/function_handler.rb +42 -0
- data/lib/puppet-strings/yard/handlers/ruby/base.rb +38 -0
- data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +357 -0
- data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +113 -0
- data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +194 -0
- data/lib/puppet-strings/yard/parsers.rb +7 -0
- data/lib/puppet-strings/yard/parsers/puppet/parser.rb +70 -0
- data/lib/puppet-strings/yard/parsers/puppet/statement.rb +146 -0
- data/lib/puppet-strings/yard/tags.rb +6 -0
- data/lib/puppet-strings/yard/tags/overload_tag.rb +109 -0
- data/lib/puppet-strings/yard/tags/parameter_directive.rb +24 -0
- data/lib/puppet-strings/yard/tags/property_directive.rb +24 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_class.erb +9 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_defined_type.erb +9 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_function.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_provider.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_type.erb +9 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +64 -0
- data/lib/puppet-strings/yard/templates/default/layout/html/objects.erb +35 -0
- data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +172 -0
- data/lib/puppet-strings/yard/templates/default/puppet_class/html/box_info.erb +26 -0
- data/lib/puppet-strings/yard/templates/default/puppet_class/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_class/html/overview.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb +14 -0
- data/lib/puppet-strings/yard/templates/default/puppet_class/html/source.erb +12 -0
- data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/box_info.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/overview.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb +5 -0
- data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/source.erb +12 -0
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/box_info.erb +14 -0
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/overview.erb +18 -0
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +5 -0
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/source.erb +12 -0
- data/lib/puppet-strings/yard/templates/default/puppet_provider/html/box_info.erb +14 -0
- data/lib/puppet-strings/yard/templates/default/puppet_provider/html/collection.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/puppet_provider/html/features.erb +12 -0
- data/lib/puppet-strings/yard/templates/default/puppet_provider/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_provider/html/overview.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb +29 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/box_info.erb +20 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/features.erb +13 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/overview.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/parameters.erb +35 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +32 -0
- data/lib/puppet-strings/yard/templates/default/tags/html/puppet_overload.erb +12 -0
- data/lib/puppet-strings/yard/templates/default/tags/setup.rb +15 -0
- data/lib/puppet/application/strings.rb +1 -0
- data/lib/puppet/face/strings.rb +80 -39
- data/spec/acceptance/emit_json_options.rb +41 -0
- data/spec/acceptance/lib/util.rb +15 -0
- data/spec/acceptance/running_strings_generate.rb +54 -0
- data/spec/fixtures/acceptance/modules/test/functions/add.pp +9 -0
- data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +5 -0
- data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +2 -0
- data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +9 -0
- data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +15 -0
- data/spec/fixtures/acceptance/modules/test/manifests/init.pp +27 -0
- data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +27 -0
- data/spec/fixtures/acceptance/modules/test/metadata.json +6 -0
- data/spec/fixtures/unit/json/output.json +348 -0
- data/spec/fixtures/unit/json/output_without_puppet_function.json +301 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/spec_helper_acceptance.rb +27 -0
- data/spec/unit/puppet-strings/json_spec.rb +136 -0
- data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +155 -0
- data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +155 -0
- data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +169 -0
- data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +613 -0
- data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +90 -0
- data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +214 -0
- data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +171 -0
- metadata +115 -92
- data/lib/puppet-strings/rake_tasks.rb +0 -18
- data/lib/puppet_x/puppetlabs/strings.rb +0 -64
- data/lib/puppet_x/puppetlabs/strings/actions.rb +0 -92
- data/lib/puppet_x/puppetlabs/strings/pops/yard_statement.rb +0 -79
- data/lib/puppet_x/puppetlabs/strings/pops/yard_transformer.rb +0 -47
- data/lib/puppet_x/puppetlabs/strings/util.rb +0 -65
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/defined_type_object.rb +0 -33
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/host_class_object.rb +0 -22
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/method_object.rb +0 -62
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/provider_object.rb +0 -24
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/puppet_namespace_object.rb +0 -48
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/type_object.rb +0 -42
- data/lib/puppet_x/puppetlabs/strings/yard/core_ext/yard.rb +0 -40
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/base.rb +0 -13
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/defined_type_handler.rb +0 -31
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/heredoc_helper.rb +0 -80
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb +0 -42
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/provider_handler.rb +0 -95
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_3x_function_handler.rb +0 -54
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_4x_function_handler.rb +0 -234
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb +0 -295
- data/lib/puppet_x/puppetlabs/strings/yard/json_registry_store.rb +0 -85
- data/lib/puppet_x/puppetlabs/strings/yard/monkey_patches.rb +0 -68
- data/lib/puppet_x/puppetlabs/strings/yard/parser.rb +0 -30
- data/lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb +0 -9
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/docstring.erb +0 -34
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/header.erb +0 -5
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/parameter_details.erb +0 -6
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/setup.rb +0 -1
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/setup.rb +0 -49
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_class.erb +0 -2
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_manifest.erb +0 -1
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_plugin.erb +0 -21
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_provider.erb +0 -1
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_type.erb +0 -1
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb +0 -82
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/box_info.erb +0 -22
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/setup.rb +0 -1
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/subclasses.erb +0 -4
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/setup.rb +0 -21
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/html_helper.rb +0 -139
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/layout/html/setup.rb +0 -18
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/html/header.erb +0 -17
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/setup.rb +0 -21
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/text/header.erb +0 -2
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/command_details.erb +0 -8
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/confine_details.erb +0 -10
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/default_details.erb +0 -10
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/docstring.erb +0 -34
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/feature_details.erb +0 -10
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/header.erb +0 -5
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/setup.rb +0 -1
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/setup.rb +0 -50
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/box_info.erb +0 -11
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/header.erb +0 -5
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/method_details_list.erb +0 -53
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/method_summary.erb +0 -20
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/setup.rb +0 -1
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/setup.rb +0 -91
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/template_helper.rb +0 -192
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/docstring.erb +0 -34
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/header.erb +0 -5
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/parameter_details.erb +0 -12
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/provider_details.erb +0 -10
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/setup.rb +0 -1
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/setup.rb +0 -55
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Defined Type: <%= object.name %></h1>
|
@@ -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> ⇒ #{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,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,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,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? %> — <%= 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,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> ⇒ #{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
|
data/lib/puppet/face/strings.rb
CHANGED
@@ -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
|
5
|
+
summary 'Generate Puppet documentation with YARD.'
|
6
6
|
|
7
|
-
|
8
|
-
|
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
|
-
|
14
|
-
|
10
|
+
option '--emit-json-stdout' do
|
11
|
+
summary 'Print JSON representation of the documentation to stdout.'
|
15
12
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
23
|
-
|
20
|
+
summary 'Generate documentation from files.'
|
21
|
+
arguments '[[search_pattern] ...]'
|
24
22
|
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
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
|
33
|
-
arguments
|
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 '
|
45
|
+
require 'puppet-strings'
|
46
|
+
|
47
|
+
modules = args.count > 1 ? args[0..-2] : []
|
38
48
|
|
39
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
#
|
50
|
-
#
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
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
|