puppet-strings 2.1.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +78 -4
- data/CONTRIBUTING.md +32 -2
- data/README.md +81 -17
- data/lib/puppet-strings.rb +13 -4
- data/lib/puppet-strings/describe.rb +68 -0
- data/lib/puppet-strings/json.rb +2 -38
- data/lib/puppet-strings/markdown.rb +3 -1
- data/lib/puppet-strings/markdown/base.rb +37 -16
- data/lib/puppet-strings/markdown/data_type.rb +34 -0
- data/lib/puppet-strings/markdown/data_types.rb +41 -0
- data/lib/puppet-strings/markdown/function.rb +2 -2
- data/lib/puppet-strings/markdown/resource_type.rb +19 -2
- data/lib/puppet-strings/markdown/table_of_contents.rb +1 -0
- data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +12 -4
- data/lib/puppet-strings/markdown/templates/data_type.erb +93 -0
- data/lib/puppet-strings/markdown/templates/data_type_function.erb +67 -0
- data/lib/puppet-strings/markdown/templates/function.erb +36 -1
- data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
- data/lib/puppet-strings/markdown/templates/resource_type.erb +32 -12
- data/lib/puppet-strings/markdown/templates/table_of_contents.erb +6 -6
- data/lib/puppet-strings/tasks/generate.rb +10 -3
- data/lib/puppet-strings/version.rb +1 -1
- data/lib/puppet-strings/yard.rb +16 -0
- data/lib/puppet-strings/yard/code_objects.rb +2 -0
- data/lib/puppet-strings/yard/code_objects/class.rb +2 -2
- data/lib/puppet-strings/yard/code_objects/data_type.rb +100 -0
- data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +58 -0
- data/lib/puppet-strings/yard/code_objects/defined_type.rb +2 -2
- data/lib/puppet-strings/yard/code_objects/function.rb +4 -4
- data/lib/puppet-strings/yard/code_objects/plan.rb +2 -2
- data/lib/puppet-strings/yard/code_objects/provider.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/task.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/type.rb +48 -6
- data/lib/puppet-strings/yard/handlers.rb +3 -0
- data/lib/puppet-strings/yard/handlers/puppet/data_type_alias_handler.rb +24 -0
- data/lib/puppet-strings/yard/handlers/ruby/base.rb +12 -1
- data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +393 -0
- data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +2 -12
- data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +1 -9
- data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +3 -3
- data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +135 -0
- data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +56 -0
- data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +9 -115
- data/lib/puppet-strings/yard/parsers/json/parser.rb +4 -2
- data/lib/puppet-strings/yard/parsers/puppet/parser.rb +14 -7
- data/lib/puppet-strings/yard/parsers/puppet/statement.rb +25 -0
- data/lib/puppet-strings/yard/tags.rb +2 -0
- data/lib/puppet-strings/yard/tags/enum_tag.rb +12 -0
- data/lib/puppet-strings/yard/tags/factory.rb +16 -0
- data/lib/puppet-strings/yard/tags/overload_tag.rb +2 -2
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_data_type.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +9 -0
- data/lib/puppet-strings/yard/templates/default/layout/html/objects.erb +2 -0
- data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +18 -1
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/box_info.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/method_details_list.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/note.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/overview.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +13 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/source.erb +12 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/summary.erb +4 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/todo.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/alias_of.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/box_info.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/note.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/overview.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb +17 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/source.erb +12 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/summary.erb +4 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/todo.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +3 -1
- data/lib/puppet-strings/yard/templates/default/tags/html/enum.erb +17 -0
- data/lib/puppet-strings/yard/templates/default/tags/setup.rb +7 -0
- data/lib/puppet-strings/yard/util.rb +48 -0
- data/lib/puppet/face/strings.rb +68 -3
- metadata +36 -45
- data/Gemfile +0 -37
- data/HISTORY.md +0 -218
- data/JSON.md +0 -802
- data/Rakefile +0 -93
- data/codecov.yml +0 -3
- data/misc/ANNOUNCEMENT_TEMPLATE.md +0 -40
- data/spec/acceptance/emit_json_options.rb +0 -71
- data/spec/acceptance/generate_markdown_spec.rb +0 -49
- data/spec/acceptance/lib/util.rb +0 -163
- data/spec/acceptance/running_strings_generate.rb +0 -54
- data/spec/fixtures/acceptance/modules/test/functions/add.pp +0 -9
- data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +0 -5
- data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +0 -2
- data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +0 -9
- data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +0 -15
- data/spec/fixtures/acceptance/modules/test/manifests/init.pp +0 -27
- data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +0 -27
- data/spec/fixtures/acceptance/modules/test/metadata.json +0 -6
- data/spec/fixtures/unit/json/output.json +0 -660
- data/spec/fixtures/unit/json/output_with_plan.json +0 -697
- data/spec/fixtures/unit/json/output_without_puppet_function.json +0 -480
- data/spec/fixtures/unit/markdown/output.md +0 -444
- data/spec/fixtures/unit/markdown/output_with_plan.md +0 -478
- data/spec/spec_helper.rb +0 -45
- data/spec/spec_helper_acceptance.rb +0 -28
- data/spec/unit/puppet-strings/json_spec.rb +0 -229
- data/spec/unit/puppet-strings/markdown/base_spec.rb +0 -146
- data/spec/unit/puppet-strings/markdown_spec.rb +0 -283
- data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +0 -92
- data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +0 -124
- data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +0 -217
- data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +0 -231
- data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +0 -315
- data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +0 -729
- data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +0 -139
- data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +0 -214
- data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +0 -269
- data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +0 -70
- data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +0 -56
- data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +0 -209
- data/spec/unit/puppet-strings/yard/util_spec.rb +0 -48
|
@@ -41,41 +41,48 @@ class PuppetStrings::Yard::Parsers::Puppet::Parser < YARD::Parser::Base
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
private
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
def transform_Program(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
45
46
|
# Cache the lines of the source text; we'll use this to locate comments
|
|
46
47
|
@lines = o.source_text.lines.to_a
|
|
47
48
|
o.definitions.map { |d| @visitor.visit(d) }
|
|
48
49
|
end
|
|
49
50
|
|
|
50
|
-
def transform_Factory(o)
|
|
51
|
+
def transform_Factory(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
51
52
|
@visitor.visit(o.current)
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
def transform_HostClassDefinition(o)
|
|
55
|
+
def transform_HostClassDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
55
56
|
statement = PuppetStrings::Yard::Parsers::Puppet::ClassStatement.new(o, @file)
|
|
56
57
|
statement.extract_docstring(@lines)
|
|
57
58
|
statement
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
def transform_ResourceTypeDefinition(o)
|
|
61
|
+
def transform_ResourceTypeDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
61
62
|
statement = PuppetStrings::Yard::Parsers::Puppet::DefinedTypeStatement.new(o, @file)
|
|
62
63
|
statement.extract_docstring(@lines)
|
|
63
64
|
statement
|
|
64
65
|
end
|
|
65
66
|
|
|
66
|
-
def transform_FunctionDefinition(o)
|
|
67
|
+
def transform_FunctionDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
67
68
|
statement = PuppetStrings::Yard::Parsers::Puppet::FunctionStatement.new(o, @file)
|
|
68
69
|
statement.extract_docstring(@lines)
|
|
69
70
|
statement
|
|
70
71
|
end
|
|
71
72
|
|
|
72
|
-
def transform_PlanDefinition(o)
|
|
73
|
+
def transform_PlanDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
73
74
|
statement = PuppetStrings::Yard::Parsers::Puppet::PlanStatement.new(o, @file)
|
|
74
75
|
statement.extract_docstring(@lines)
|
|
75
76
|
statement
|
|
76
77
|
end
|
|
77
78
|
|
|
78
|
-
def
|
|
79
|
+
def transform_TypeAlias(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
80
|
+
statement = PuppetStrings::Yard::Parsers::Puppet::DataTypeAliasStatement.new(o, @file)
|
|
81
|
+
statement.extract_docstring(@lines)
|
|
82
|
+
statement
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def transform_Object(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
79
86
|
# Ignore anything else (will be compacted out of the resulting array)
|
|
80
87
|
end
|
|
81
88
|
end
|
|
@@ -165,4 +165,29 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
|
165
165
|
end
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
+
# Implements the Puppet data type alias statement.
|
|
169
|
+
class DataTypeAliasStatement < Statement
|
|
170
|
+
attr_reader :name
|
|
171
|
+
attr_reader :alias_of
|
|
172
|
+
|
|
173
|
+
# Initializes the Puppet data type alias statement.
|
|
174
|
+
# @param [Puppet::Pops::Model::TypeAlias] object The model object for the type statement.
|
|
175
|
+
# @param [String] file The file containing the statement.
|
|
176
|
+
def initialize(object, file)
|
|
177
|
+
super(object, file)
|
|
178
|
+
|
|
179
|
+
type_expr = object.type_expr
|
|
180
|
+
case type_expr
|
|
181
|
+
when Puppet::Pops::Model::AccessExpression
|
|
182
|
+
# TODO: I don't like rebuilding the source from the AST, but AccessExpressions don't expose the original source
|
|
183
|
+
@alias_of = ::Puppet::Pops::Adapters::SourcePosAdapter.adapt(type_expr.left_expr).extract_text + '['
|
|
184
|
+
@alias_of << type_expr.keys.map { |key| ::Puppet::Pops::Adapters::SourcePosAdapter.adapt(key).extract_text }.join(', ')
|
|
185
|
+
@alias_of << ']'
|
|
186
|
+
else
|
|
187
|
+
adapter = ::Puppet::Pops::Adapters::SourcePosAdapter.adapt(type_expr)
|
|
188
|
+
@alias_of = adapter.extract_text
|
|
189
|
+
end
|
|
190
|
+
@name = object.name
|
|
191
|
+
end
|
|
192
|
+
end
|
|
168
193
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# The module for custom YARD tags.
|
|
2
2
|
module PuppetStrings::Yard::Tags
|
|
3
|
+
require 'puppet-strings/yard/tags/factory'
|
|
3
4
|
require 'puppet-strings/yard/tags/parameter_directive'
|
|
4
5
|
require 'puppet-strings/yard/tags/property_directive'
|
|
5
6
|
require 'puppet-strings/yard/tags/overload_tag'
|
|
6
7
|
require 'puppet-strings/yard/tags/summary_tag'
|
|
8
|
+
require 'puppet-strings/yard/tags/enum_tag'
|
|
7
9
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'yard/tags/option_tag'
|
|
2
|
+
|
|
3
|
+
# Implements an enum tag for describing enumerated value data types
|
|
4
|
+
|
|
5
|
+
class PuppetStrings::Yard::Tags::EnumTag < YARD::Tags::OptionTag
|
|
6
|
+
# Registers the tag with YARD.
|
|
7
|
+
# @return [void]
|
|
8
|
+
def self.register!
|
|
9
|
+
YARD::Tags::Library.define_tag("puppet.enum", :enum, :with_enums)
|
|
10
|
+
YARD::Tags::Library.visible_tags.place(:enum).after(:option)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'yard/tags/default_factory'
|
|
2
|
+
require 'puppet-strings/yard/tags/enum_tag'
|
|
3
|
+
|
|
4
|
+
class PuppetStrings::Yard::Tags::Factory < YARD::Tags::DefaultFactory
|
|
5
|
+
|
|
6
|
+
# Parses tag text and creates a new enum tag type. Modeled after
|
|
7
|
+
# the parse_tag_with_options method in YARD::Tags::DefaultFactory.
|
|
8
|
+
#
|
|
9
|
+
# @param tag_name the name of the tag to parse
|
|
10
|
+
# @param [String] text the raw tag text
|
|
11
|
+
# @return [Tag] a tag object with the tag_name, name, and nested Tag as type
|
|
12
|
+
def parse_tag_with_enums(tag_name, text)
|
|
13
|
+
name, text = *extract_name_from_text(text)
|
|
14
|
+
PuppetStrings::Yard::Tags::EnumTag.new(tag_name, name, parse_tag_with_name(tag_name, text))
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -99,8 +99,8 @@ class PuppetStrings::Yard::Tags::OverloadTag < YARD::Tags::Tag
|
|
|
99
99
|
hash[:tag_name] = tag_name
|
|
100
100
|
hash[:text] = text if text
|
|
101
101
|
hash[:signature] = signature
|
|
102
|
-
hash[:docstring] = PuppetStrings::
|
|
103
|
-
defaults = Hash[*parameters.
|
|
102
|
+
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) if !docstring.blank?
|
|
103
|
+
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
|
|
104
104
|
hash[:defaults] = defaults unless defaults.empty?
|
|
105
105
|
hash[:types] = types if types
|
|
106
106
|
hash[:name] = name if name
|
|
@@ -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
|
+
<% if item.type == :puppet_data_type_alias %><small>Alias</small><% end %>
|
|
7
|
+
</div>
|
|
8
|
+
</li>
|
|
9
|
+
<% even = !even %>
|
|
10
|
+
<% end %>
|
|
@@ -7,6 +7,15 @@ def generate_puppet_class_list
|
|
|
7
7
|
generate_list_contents
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
# Generates the searchable Puppet data type list.
|
|
11
|
+
# @return [void]
|
|
12
|
+
def generate_puppet_data_type_list
|
|
13
|
+
@items = Registry.all(:puppet_data_type, :puppet_data_type_alias).sort_by {|dt| dt.name.to_s }
|
|
14
|
+
@list_title = 'Data Type List'
|
|
15
|
+
@list_type = 'puppet_data_type'
|
|
16
|
+
generate_list_contents
|
|
17
|
+
end
|
|
18
|
+
|
|
10
19
|
# Generates the searchable Puppet defined type list.
|
|
11
20
|
# @return [void]
|
|
12
21
|
def generate_puppet_defined_type_list
|
|
@@ -4,7 +4,7 @@ def init
|
|
|
4
4
|
case object
|
|
5
5
|
when '_index.html'
|
|
6
6
|
@page_title = options.title
|
|
7
|
-
sections :layout, [:index, [:listing, [:classes, :defined_types, :types, :providers, :functions, :tasks, :plans, :files, :objects]]]
|
|
7
|
+
sections :layout, [:index, [:listing, [:classes, :data_types, :defined_types, :types, :providers, :functions, :tasks, :plans, :files, :objects]]]
|
|
8
8
|
else
|
|
9
9
|
super
|
|
10
10
|
end
|
|
@@ -30,6 +30,10 @@ def layout
|
|
|
30
30
|
@nav_url = url_for_list('puppet_class')
|
|
31
31
|
@page_title = "Puppet Class: #{object.name}"
|
|
32
32
|
@path = object.path
|
|
33
|
+
when PuppetStrings::Yard::CodeObjects::DataType, PuppetStrings::Yard::CodeObjects::DataTypeAlias
|
|
34
|
+
@nav_url = url_for_list('puppet_data_type')
|
|
35
|
+
@page_title = "Data Type: #{object.name}"
|
|
36
|
+
@path = object.path
|
|
33
37
|
when PuppetStrings::Yard::CodeObjects::DefinedType
|
|
34
38
|
@nav_url = url_for_list('puppet_defined_type')
|
|
35
39
|
@page_title = "Defined Type: #{object.name}"
|
|
@@ -76,6 +80,11 @@ def create_menu_lists
|
|
|
76
80
|
title: 'Puppet Classes',
|
|
77
81
|
search_title: 'Puppet Classes'
|
|
78
82
|
},
|
|
83
|
+
{
|
|
84
|
+
type: 'puppet_data_type',
|
|
85
|
+
title: 'Data Types',
|
|
86
|
+
search_title: 'Data Types',
|
|
87
|
+
},
|
|
79
88
|
{
|
|
80
89
|
type: 'puppet_defined_type',
|
|
81
90
|
title: 'Defined Types',
|
|
@@ -155,6 +164,14 @@ def classes
|
|
|
155
164
|
erb(:objects)
|
|
156
165
|
end
|
|
157
166
|
|
|
167
|
+
# Renders the data types section.
|
|
168
|
+
# @return [String] Returns the rendered section.
|
|
169
|
+
def data_types
|
|
170
|
+
@title = 'Data Type Listing A-Z'
|
|
171
|
+
@objects_by_letter = objects_by_letter(:puppet_data_type, :puppet_data_type_alias)
|
|
172
|
+
erb(:objects)
|
|
173
|
+
end
|
|
174
|
+
|
|
158
175
|
# Renders the defined types section.
|
|
159
176
|
# @return [String] Returns the rendered section.
|
|
160
177
|
def defined_types
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Puppet Data Type: <%= object.name %></h1>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Initializes the template.
|
|
2
|
+
# @return [void]
|
|
3
|
+
def init
|
|
4
|
+
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :method_details_list, [T('method_details')], :source
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def method_listing
|
|
8
|
+
sort_listing(object.functions)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def sort_listing(list)
|
|
12
|
+
list.sort_by {|o| [o.scope.to_s, o.name.to_s.downcase] }
|
|
13
|
+
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,10 @@
|
|
|
1
|
+
<% if @alias_of && !@alias_of.empty? %>
|
|
2
|
+
<div class="tags">
|
|
3
|
+
<p class="tag_title"><%= @tag_title %></p>
|
|
4
|
+
<div class="docstring">
|
|
5
|
+
<div class="discussion">
|
|
6
|
+
<pre class="code"><span class="info"><%= @alias_of %></span></pre>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Puppet Data Type Alias: <%= object.name %></h1>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Initializes the template.
|
|
2
|
+
# @return [void]
|
|
3
|
+
def init
|
|
4
|
+
sections :header, :box_info, :summary, :overview, :alias_of, :note, :todo, T('tags'), :source
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
# Renders the alias_of section.
|
|
8
|
+
# @return [String] Returns the rendered section.
|
|
9
|
+
def alias_of
|
|
10
|
+
# Properties are the same thing as parameters (from the documentation standpoint),
|
|
11
|
+
# so reuse the same template but with a different title and data source.
|
|
12
|
+
#@parameters = object.properties || []
|
|
13
|
+
#@parameters.sort_by! { |p| p.name }
|
|
14
|
+
@tag_title = 'Alias of'
|
|
15
|
+
@alias_of = object.alias_of
|
|
16
|
+
erb(:alias_of)
|
|
17
|
+
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>
|
|
@@ -16,7 +16,9 @@ end
|
|
|
16
16
|
def properties
|
|
17
17
|
# Properties are the same thing as parameters (from the documentation standpoint),
|
|
18
18
|
# so reuse the same template but with a different title and data source.
|
|
19
|
-
|
|
19
|
+
#
|
|
20
|
+
# "checks" such as "creates" and "onlyif" are another type of property
|
|
21
|
+
@parameters = (object.properties || []) + (object.checks || [])
|
|
20
22
|
@parameters.sort_by! { |p| p.name }
|
|
21
23
|
@tag_title = 'Properties'
|
|
22
24
|
erb(:parameters)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<% if object.has_tag?(:enum) %>
|
|
2
|
+
<% object.parameters.each do |param, default| %>
|
|
3
|
+
<% tags = object.tags(:enum).select {|x| x.name.to_s == param.to_s.sub(/^\*+|:$/, '') } %>
|
|
4
|
+
<% next if tags.empty? %>
|
|
5
|
+
<p class="tag_title">Enum Options (<tt><%= param %></tt>):</p>
|
|
6
|
+
<ul class="option">
|
|
7
|
+
<% for tag in tags %>
|
|
8
|
+
<li>
|
|
9
|
+
<span class="name"><%= tag.pair.name %></span>
|
|
10
|
+
<% if tag.pair.text && tag.pair.text =~ /\S/ %>
|
|
11
|
+
— <%= htmlify_line(tag.pair.text) %>
|
|
12
|
+
<% end %>
|
|
13
|
+
</li>
|
|
14
|
+
<% end %>
|
|
15
|
+
</ul>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% end %>
|
|
@@ -4,6 +4,7 @@ def param
|
|
|
4
4
|
tag(:param) if
|
|
5
5
|
object.type == :method ||
|
|
6
6
|
object.type == :puppet_class ||
|
|
7
|
+
object.type == :puppet_data_type ||
|
|
7
8
|
object.type == :puppet_defined_type ||
|
|
8
9
|
object.type == :puppet_function ||
|
|
9
10
|
object.type == :puppet_task ||
|
|
@@ -15,3 +16,9 @@ end
|
|
|
15
16
|
def overload
|
|
16
17
|
erb(if object.type == :puppet_function then :puppet_overload else :overload end)
|
|
17
18
|
end
|
|
19
|
+
|
|
20
|
+
# Renders the enum section.
|
|
21
|
+
# @return [String] Returns the rendered section.
|
|
22
|
+
def enum
|
|
23
|
+
erb(:enum)
|
|
24
|
+
end
|
|
@@ -28,4 +28,52 @@ module PuppetStrings::Yard::Util
|
|
|
28
28
|
end
|
|
29
29
|
data
|
|
30
30
|
end
|
|
31
|
+
|
|
32
|
+
# Converts a list of tags into an array of hashes.
|
|
33
|
+
# @param [Array] tags List of tags to be converted into an array of hashes.
|
|
34
|
+
# @return [Array] Returns an array of tag hashes.
|
|
35
|
+
def self.tags_to_hashes(tags)
|
|
36
|
+
# Skip over the API tags that are public
|
|
37
|
+
tags.select { |t| (t.tag_name != 'api' || t.text != 'public') }.map do |t|
|
|
38
|
+
next t.to_hash if t.respond_to?(:to_hash)
|
|
39
|
+
|
|
40
|
+
tag = { tag_name: t.tag_name }
|
|
41
|
+
# grab nested information for @option and @enum tags
|
|
42
|
+
if tag[:tag_name] == 'option' || tag[:tag_name] == 'enum'
|
|
43
|
+
tag[:opt_name] = t.pair.name
|
|
44
|
+
tag[:opt_text] = t.pair.text
|
|
45
|
+
tag[:opt_types] = t.pair.types if t.pair.types
|
|
46
|
+
tag[:parent] = t.name
|
|
47
|
+
end
|
|
48
|
+
tag[:text] = t.text if t.text
|
|
49
|
+
tag[:types] = t.types if t.types
|
|
50
|
+
tag[:name] = t.name if t.name
|
|
51
|
+
tag
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Converts a YARD::Docstring (or String) to a docstring hash for JSON output.
|
|
56
|
+
# @param [YARD::Docstring, String] docstring The docstring to convert to a hash.
|
|
57
|
+
# @param [Array] select_tags List of tags to select. Other tags will be filtered out.
|
|
58
|
+
# @return [Hash] Returns a hash representation of the given docstring.
|
|
59
|
+
def self.docstring_to_hash(docstring, select_tags=nil)
|
|
60
|
+
hash = {}
|
|
61
|
+
hash[:text] = docstring
|
|
62
|
+
|
|
63
|
+
if docstring.is_a? YARD::Docstring
|
|
64
|
+
tags = tags_to_hashes(docstring.tags.select { |t| select_tags.nil? || select_tags.include?(t.tag_name.to_sym) })
|
|
65
|
+
|
|
66
|
+
unless tags.empty?
|
|
67
|
+
hash[:tags] = tags
|
|
68
|
+
# .sort_by do |tag|
|
|
69
|
+
# sort_key = tag[:tag_name].dup
|
|
70
|
+
# sort_key << "-#{tag[:name]}" if tag[:name]
|
|
71
|
+
# sort_key << "-#{tag[:opt_name]}" if tag[:opt_name]
|
|
72
|
+
# sort_key
|
|
73
|
+
# end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
hash
|
|
78
|
+
end
|
|
31
79
|
end
|