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,24 @@
1
+ require 'puppet-strings/yard/code_objects'
2
+
3
+ # Implements a parameter directive (e.g. #@!puppet.type.param) for documenting Puppet resource types.
4
+ class PuppetStrings::Yard::Tags::ParameterDirective < YARD::Tags::Directive
5
+ # Called to invoke the directive.
6
+ # @return [void]
7
+ def call
8
+ return unless object && object.respond_to?(:add_parameter)
9
+ # Add a parameter to the resource
10
+ parameter = PuppetStrings::Yard::CodeObjects::Type::Parameter.new(tag.name, tag.text)
11
+ if tag.types
12
+ tag.types.each do |value|
13
+ parameter.add(value)
14
+ end
15
+ end
16
+ object.add_parameter parameter
17
+ end
18
+
19
+ # Registers the directive with YARD.
20
+ # @return [void]
21
+ def self.register!
22
+ YARD::Tags::Library.define_directive('puppet.type.param', :with_types_and_name, self)
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'puppet-strings/yard/code_objects'
2
+
3
+ # Implements a parameter directive (e.g. #@!puppet.type.property) for documenting Puppet resource types.
4
+ class PuppetStrings::Yard::Tags::PropertyDirective < YARD::Tags::Directive
5
+ # Called to invoke the directive.
6
+ # @return [void]
7
+ def call
8
+ return unless object && object.respond_to?(:add_property)
9
+ # Add a property to the resource
10
+ property = PuppetStrings::Yard::CodeObjects::Type::Property.new(tag.name, tag.text)
11
+ if tag.types
12
+ tag.types.each do |value|
13
+ property.add(value)
14
+ end
15
+ end
16
+ object.add_property property
17
+ end
18
+
19
+ # Registers the directive with YARD.
20
+ # @return [void]
21
+ def self.register!
22
+ YARD::Tags::Library.define_directive('puppet.type.property', :with_types_and_name, self)
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ <% even = false %>
2
+ <% @items.each do |item| %>
3
+ <li id="object_<%=item.path%>" class="<%= even ? 'even' : 'odd' %>">
4
+ <div class="item">
5
+ <%= linkify item, h(item.name(true)) %>
6
+ </div>
7
+ </li>
8
+ <% even = !even %>
9
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <% even = false %>
2
+ <% @items.each do |item| %>
3
+ <li id="object_<%=item.path%>" class="<%= even ? 'even' : 'odd' %>">
4
+ <div class="item">
5
+ <%= linkify item, h(item.name(true)) %>
6
+ </div>
7
+ </li>
8
+ <% even = !even %>
9
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% even = false %>
2
+ <% @items.each do |item| %>
3
+ <li id="object_<%=item.path%>" class="<%= even ? 'even' : 'odd' %>">
4
+ <div class="item">
5
+ <%= linkify item, h(item.name(false)) %>
6
+ <small><%= item.function_type %></small>
7
+ </div>
8
+ </li>
9
+ <% even = !even %>
10
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% even = false %>
2
+ <% @items.each do |item| %>
3
+ <li id="object_<%=item.path%>" class="<%= even ? 'even' : 'odd' %>">
4
+ <div class="item">
5
+ <%= linkify item, h(item.name(true)) %>
6
+ <small>Resource type: <em><%=item.type_name%></em></small>
7
+ </div>
8
+ </li>
9
+ <% even = !even %>
10
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <% even = false %>
2
+ <% @items.each do |item| %>
3
+ <li id="object_<%=item.path%>" class="<%= even ? 'even' : 'odd' %>">
4
+ <div class="item">
5
+ <%= linkify item, h(item.name(true)) %>
6
+ </div>
7
+ </li>
8
+ <% even = !even %>
9
+ <% end %>
@@ -0,0 +1,64 @@
1
+ # Generates the searchable Puppet class list.
2
+ # @return [void]
3
+ def generate_puppet_class_list
4
+ @items = Registry.all(:puppet_class).sort_by { |c| c.name.to_s }
5
+ @list_title = 'Puppet Class List'
6
+ @list_type = 'puppet_class'
7
+ generate_list_contents
8
+ end
9
+
10
+ # Generates the searchable Puppet defined type list.
11
+ # @return [void]
12
+ def generate_puppet_defined_type_list
13
+ @items = Registry.all(:puppet_defined_type).sort_by {|dt| dt.name.to_s }
14
+ @list_title = 'Defined Type List'
15
+ @list_type = 'puppet_defined_type'
16
+ generate_list_contents
17
+ end
18
+
19
+ # Generates the searchable Puppet resource type list.
20
+ # @return [void]
21
+ def generate_puppet_type_list
22
+ @items = Registry.all(:puppet_type).sort_by {|t| t.name.to_s }
23
+ @list_title = 'Resource Type List'
24
+ @list_type = 'puppet_type'
25
+ generate_list_contents
26
+ end
27
+
28
+ # Generates the searchable Puppet provider list.
29
+ # @return [void]
30
+ def generate_puppet_provider_list
31
+ @items = Registry.all(:puppet_provider).sort_by {|p| p.name.to_s }
32
+ @list_title = 'Provider List'
33
+ @list_type = 'puppet_provider'
34
+ generate_list_contents
35
+ end
36
+
37
+ # Generates the searchable Puppet function list.
38
+ # @return [void]
39
+ def generate_puppet_function_list
40
+ @items = Registry.all(:puppet_function).sort_by {|f| f.name.to_s }
41
+ @list_title = 'Puppet Function List'
42
+ @list_type = 'puppet_function'
43
+ generate_list_contents
44
+ end
45
+
46
+ # Generates the searchable Ruby method list.
47
+ # @return [void]
48
+ def generate_method_list
49
+ @items = prune_method_listing(Registry.all(:method), false)
50
+ @items = @items.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? }
51
+ @items = @items.sort_by {|m| m.name.to_s }
52
+ @list_title = 'Ruby Method List'
53
+ @list_type = 'method'
54
+ generate_list_contents
55
+ end
56
+
57
+ # Generate a searchable Ruby class list in the output.
58
+ # @return [void]
59
+ def generate_class_list
60
+ @items = options.objects if options.objects
61
+ @list_title = 'Ruby Class List'
62
+ @list_type = 'class'
63
+ generate_list_contents
64
+ end
@@ -0,0 +1,35 @@
1
+ <% unless @objects_by_letter.empty? %>
2
+ <h2><%= @title %></h2>
3
+
4
+ <% i = 0 %>
5
+ <table>
6
+ <tr>
7
+ <td valign='top' width="33%">
8
+ <% @objects_by_letter.sort_by {|l,o| l.to_s }.each do |letter, objects| %>
9
+ <% if (i += 1) % 8 == 0 %>
10
+ </td>
11
+ <td valign='top' width="33%">
12
+ <% i = 0 %>
13
+ <% end %>
14
+ <ul id="alpha_<%= letter %>" class="alpha">
15
+ <li class="letter"><%= letter %></li>
16
+ <ul>
17
+ <% objects.each do |obj| %>
18
+ <li>
19
+ <%= linkify obj, obj.name %>
20
+ <% if (obj.type == :module || obj.type == :class) && !obj.namespace.root? %>
21
+ <small>(<%= obj.namespace.path %>)</small>
22
+ <% elsif obj.type == :puppet_provider %>
23
+ <small>(Resource type: <%= obj.type_name %>)</small>
24
+ <% elsif obj.type == :puppet_function %>
25
+ <small>(<%= obj.function_type %>)</small>
26
+ <% end %>
27
+ </li>
28
+ <% end %>
29
+ </ul>
30
+ </ul>
31
+ <% end %>
32
+ </td>
33
+ </tr>
34
+ </table>
35
+ <% end %>
@@ -0,0 +1,172 @@
1
+ # Initializes the template.
2
+ # @return [void]
3
+ def init
4
+ case object
5
+ when '_index.html'
6
+ @page_title = options.title
7
+ sections :layout, [:index, [:listing, [:classes, :defined_types, :types, :providers, :functions, :files, :objects]]]
8
+ else
9
+ super
10
+ end
11
+ end
12
+
13
+ # Renders the layout section.
14
+ # @return [String] Returns the rendered section.
15
+ def layout
16
+ @nav_url = url_for_list(!@file || options.index ? menu_lists.first[:type] : 'file')
17
+
18
+ case object
19
+ when nil, String
20
+ @path = nil
21
+ when @file
22
+ @path = @file.path
23
+ when !object.is_a?(YARD::CodeObjects::NamespaceObject)
24
+ @path = object.parent.path
25
+ @nav_url = url_for_list('class')
26
+ when YARD::CodeObjects::ClassObject
27
+ @path = object.path
28
+ @nav_url = url_for_list('class')
29
+ when PuppetStrings::Yard::CodeObjects::Class
30
+ @nav_url = url_for_list('puppet_class')
31
+ @page_title = "Puppet Class: #{object.name}"
32
+ @path = object.path
33
+ when PuppetStrings::Yard::CodeObjects::DefinedType
34
+ @nav_url = url_for_list('puppet_defined_type')
35
+ @page_title = "Defined Type: #{object.name}"
36
+ @path = object.path
37
+ when PuppetStrings::Yard::CodeObjects::Type
38
+ @nav_url = url_for_list('puppet_type')
39
+ @page_title = "Resource Type: #{object.name}"
40
+ @path = object.path
41
+ when PuppetStrings::Yard::CodeObjects::Provider
42
+ @nav_url = url_for_list('puppet_provider')
43
+ @page_title = "Provider: #{object.name}"
44
+ @path = object.path
45
+ when PuppetStrings::Yard::CodeObjects::Function
46
+ @nav_url = url_for_list('puppet_function')
47
+ @page_title = "Puppet Function: #{object.name} (#{object.function_type})"
48
+ @path = object.path
49
+ else
50
+ @path = object.path
51
+ end
52
+
53
+ erb(:layout)
54
+ end
55
+
56
+ # Creates the dynamic menu lists.
57
+ # @return [Array<Hash>] Returns the dynamic menu list.
58
+ def create_menu_lists
59
+ menu_lists = [
60
+ {
61
+ type: 'puppet_class',
62
+ title: 'Puppet Classes',
63
+ search_title: 'Puppet Classes'
64
+ },
65
+ {
66
+ type: 'puppet_defined_type',
67
+ title: 'Defined Types',
68
+ search_title: 'Defined Types',
69
+ },
70
+ {
71
+ type: 'puppet_type',
72
+ title: 'Resource Types',
73
+ search_title: 'Resource Types'
74
+ },
75
+ {
76
+ type: 'puppet_provider',
77
+ title: 'Providers',
78
+ search_title: 'Providers'
79
+ },
80
+ {
81
+ type: 'puppet_function',
82
+ title: 'Puppet Functions',
83
+ search_title: 'Puppet Functions'
84
+ },
85
+ {
86
+ type: 'class',
87
+ title: 'Ruby Classes',
88
+ search_title: 'Class List'
89
+ },
90
+ {
91
+ type: 'method',
92
+ title: 'Ruby Methods',
93
+ search_title: 'Method List'
94
+ },
95
+ ]
96
+
97
+ menu_lists.delete_if { |e| YARD::Registry.all(e[:type].intern).empty? }
98
+
99
+ # We must always return at least one group, so always keep the files list
100
+ menu_lists << {
101
+ type: 'file',
102
+ title: 'Files',
103
+ search_title: 'File List'
104
+ } if menu_lists.empty? || !YARD::Registry.all(:file).empty?
105
+
106
+ menu_lists
107
+ end
108
+
109
+ # Gets the menu lists to use.
110
+ # @return [Array<Hash] Returns the menu lists to use.
111
+ def menu_lists
112
+ @@lists ||= create_menu_lists.freeze
113
+ end
114
+
115
+ # Builds a list of objects by letter.
116
+ # @param [Array] types The types of objects to find.
117
+ # @return [Hash] Returns a hash of first letter of the object name to list of objects.
118
+ def objects_by_letter(*types)
119
+ hash = {}
120
+ objects = Registry.all(*types).sort_by {|o| o.name.to_s }
121
+ objects = run_verifier(objects)
122
+ objects.each {|o| (hash[o.name.to_s[0,1].upcase] ||= []) << o }
123
+ hash
124
+ end
125
+
126
+ # Renders the classes section.
127
+ # @return [String] Returns the rendered section.
128
+ def classes
129
+ @title = 'Puppet Class Listing A-Z'
130
+ @objects_by_letter = objects_by_letter(:puppet_class)
131
+ erb(:objects)
132
+ end
133
+
134
+ # Renders the defined types section.
135
+ # @return [String] Returns the rendered section.
136
+ def defined_types
137
+ @title = 'Defined Type Listing A-Z'
138
+ @objects_by_letter = objects_by_letter(:puppet_defined_type)
139
+ erb(:objects)
140
+ end
141
+
142
+ # Renders the types section.
143
+ # @return [String] Returns the rendered section.
144
+ def types
145
+ @title = 'Resource Type Listing A-Z'
146
+ @objects_by_letter = objects_by_letter(:puppet_type)
147
+ erb(:objects)
148
+ end
149
+
150
+ # Renders the providers section.
151
+ # @return [String] Returns the rendered section.
152
+ def providers
153
+ @title = 'Puppet Provider Listing A-Z'
154
+ @objects_by_letter = objects_by_letter(:puppet_provider)
155
+ erb(:objects)
156
+ end
157
+
158
+ # Renders the functions section.
159
+ # @return [String] Returns the rendered section.
160
+ def functions
161
+ @title = 'Puppet Function Listing A-Z'
162
+ @objects_by_letter = objects_by_letter(:puppet_function)
163
+ erb(:objects)
164
+ end
165
+
166
+ # Renders the objects section.
167
+ # @return [String] Returns the rendered section.
168
+ def objects
169
+ @title = 'Ruby Namespace Listing A-Z'
170
+ @objects_by_letter = objects_by_letter(:class, :module)
171
+ erb(:objects)
172
+ end
@@ -0,0 +1,26 @@
1
+ <div class="box_info">
2
+ <% if object.statement.parent_class %>
3
+ <dl>
4
+ <dt>Inherits:</dt>
5
+ <dd><%= linkify(Registry["puppet_classes::#{object.statement.parent_class}"], object.statement.parent_class.dup) %></dd>
6
+ </dl>
7
+ <% end %>
8
+ <% if @subclasses && !@subclasses.empty? %>
9
+ <dl>
10
+ <dt>Inherited by:</dt>
11
+ <dd>
12
+ <% @subclasses.each do |subclass| %>
13
+ <%= linkify(subclass, subclass.name.to_s) %><br/>
14
+ <% end %>
15
+ </dd>
16
+ </dl>
17
+ <% end %>
18
+ <dl>
19
+ <dt>Defined in:</dt>
20
+ <dd>
21
+ <%= object.file %><% if object.files.size > 1 %><span class="defines">,<br />
22
+ <%= object.files[1..-1].map {|f| f.first }.join(",<br /> ") %></div>
23
+ <% end %>
24
+ </dd>
25
+ </dl>
26
+ </div>
@@ -0,0 +1 @@
1
+ <h1>Puppet Class: <%= 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,14 @@
1
+ # Initializes the template.
2
+ # @return [void]
3
+ def init
4
+ sections :header, :box_info, :overview, T('tags'), :source
5
+ end
6
+
7
+ # Renders the box_info section.
8
+ # @return [String] Returns the rendered section.
9
+ def box_info
10
+ @subclasses = Registry.all(:puppet_class).find_all { |c|
11
+ c.statement.parent_class == object.name.to_s
12
+ }
13
+ erb(:box_info)
14
+ 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>