puppet-strings 3.0.1 → 4.0.0.rc.1
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 +13 -88
- data/LICENSE +174 -10
- data/README.md +1 -1
- data/lib/puppet/face/strings.rb +3 -3
- data/lib/puppet-strings/describe.rb +7 -11
- data/lib/puppet-strings/markdown/base.rb +6 -4
- data/lib/puppet-strings/markdown/data_type.rb +3 -4
- data/lib/puppet-strings/markdown/function.rb +5 -5
- data/lib/puppet-strings/markdown/resource_type.rb +1 -1
- data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +4 -0
- data/lib/puppet-strings/markdown/templates/data_type.erb +4 -0
- data/lib/puppet-strings/markdown/templates/function.erb +4 -0
- data/lib/puppet-strings/markdown/templates/resource_type.erb +4 -0
- data/lib/puppet-strings/markdown.rb +9 -11
- data/lib/puppet-strings/tasks/generate.rb +5 -3
- data/lib/puppet-strings/tasks/gh_pages.rb +6 -6
- data/lib/puppet-strings/tasks/validate.rb +3 -3
- data/lib/puppet-strings/tasks.rb +3 -3
- data/lib/puppet-strings/version.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/base.rb +2 -2
- data/lib/puppet-strings/yard/code_objects/class.rb +1 -2
- data/lib/puppet-strings/yard/code_objects/data_type.rb +2 -2
- data/lib/puppet-strings/yard/code_objects/defined_type.rb +1 -2
- data/lib/puppet-strings/yard/code_objects/function.rb +6 -6
- data/lib/puppet-strings/yard/code_objects/plan.rb +1 -2
- data/lib/puppet-strings/yard/code_objects/type.rb +6 -6
- data/lib/puppet-strings/yard/handlers/helpers.rb +1 -0
- data/lib/puppet-strings/yard/handlers/json/task_handler.rb +1 -0
- data/lib/puppet-strings/yard/handlers/puppet/base.rb +3 -3
- data/lib/puppet-strings/yard/handlers/ruby/base.rb +2 -2
- data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +5 -9
- data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +33 -32
- data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +1 -1
- data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +4 -4
- data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +3 -0
- data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +6 -5
- data/lib/puppet-strings/yard/parsers/json/parser.rb +1 -1
- data/lib/puppet-strings/yard/parsers/puppet/parser.rb +0 -6
- data/lib/puppet-strings/yard/parsers/puppet/statement.rb +12 -20
- data/lib/puppet-strings/yard/tags/overload_tag.rb +4 -4
- data/lib/puppet-strings/yard/tags/parameter_directive.rb +1 -1
- data/lib/puppet-strings/yard/tags/property_directive.rb +1 -1
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +11 -9
- data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +16 -14
- data/lib/puppet-strings/yard/templates/default/puppet_class/html/deprecated.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb +5 -3
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/deprecated.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +4 -2
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/deprecated.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb +5 -3
- data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/deprecated.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb +3 -1
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/deprecated.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +3 -1
- data/lib/puppet-strings/yard/templates/default/puppet_plan/html/deprecated.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb +3 -1
- data/lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb +2 -0
- data/lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb +2 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/deprecated.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +5 -3
- data/lib/puppet-strings/yard/templates/default/tags/setup.rb +3 -1
- data/lib/puppet-strings/yard/util.rb +3 -5
- data/lib/puppet-strings/yard.rb +1 -1
- data/lib/puppet-strings.rb +3 -8
- metadata +18 -13
- data/COMMITTERS.md +0 -185
@@ -8,17 +8,17 @@ require 'puppet-strings/yard/util'
|
|
8
8
|
# Implements the handler for Puppet functions written in Ruby.
|
9
9
|
class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard::Handlers::Ruby::Base
|
10
10
|
# Represents the list of Puppet 4.x function API methods to support.
|
11
|
-
DISPATCH_METHOD_NAMES = [
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
DISPATCH_METHOD_NAMES = %w[
|
12
|
+
param
|
13
|
+
required_param
|
14
|
+
optional_param
|
15
|
+
repeated_param
|
16
|
+
optional_repeated_param
|
17
|
+
required_repeated_param
|
18
|
+
block_param
|
19
|
+
required_block_param
|
20
|
+
optional_block_param
|
21
|
+
return_type
|
22
22
|
].freeze
|
23
23
|
|
24
24
|
namespace_only
|
@@ -39,7 +39,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
39
39
|
is_3x = ['Puppet::Parser::Functions', 'newfunction'].include?(module_name)
|
40
40
|
object = PuppetStrings::Yard::CodeObjects::Function.new(
|
41
41
|
get_name(statement, 'Puppet::Functions.create_function'),
|
42
|
-
is_3x ? PuppetStrings::Yard::CodeObjects::Function::RUBY_3X : PuppetStrings::Yard::CodeObjects::Function::RUBY_4X
|
42
|
+
is_3x ? PuppetStrings::Yard::CodeObjects::Function::RUBY_3X : PuppetStrings::Yard::CodeObjects::Function::RUBY_4X
|
43
43
|
)
|
44
44
|
object.source = statement
|
45
45
|
register object
|
@@ -76,21 +76,21 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
76
76
|
log.warn "Missing documentation for Puppet function '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty? && object.tags.empty?
|
77
77
|
|
78
78
|
unless object.tags(:param).empty?
|
79
|
-
log.warn "The docstring for Puppet 4.x function '#{object.name}' "\
|
80
|
-
|
81
|
-
|
79
|
+
log.warn "The docstring for Puppet 4.x function '#{object.name}' " \
|
80
|
+
"contains @param tags near #{object.file}:#{object.line}: parameter " \
|
81
|
+
'documentation should be made on the dispatch call.'
|
82
82
|
end
|
83
83
|
|
84
84
|
unless object.tags(:return).empty?
|
85
|
-
log.warn "The docstring for Puppet 4.x function '#{object.name}' "\
|
86
|
-
|
87
|
-
|
85
|
+
log.warn "The docstring for Puppet 4.x function '#{object.name}' " \
|
86
|
+
"contains @return tags near #{object.file}:#{object.line}: return " \
|
87
|
+
'value documentation should be made on the dispatch call.'
|
88
88
|
end
|
89
89
|
|
90
90
|
unless object.tags(:overload).empty?
|
91
|
-
log.warn "The docstring for Puppet 4.x function '#{object.name}' "\
|
92
|
-
|
93
|
-
|
91
|
+
log.warn "The docstring for Puppet 4.x function '#{object.name}' " \
|
92
|
+
"contains @overload tags near #{object.file}:#{object.line}: overload " \
|
93
|
+
'tags are automatically generated from the dispatch calls.'
|
94
94
|
end
|
95
95
|
|
96
96
|
# Delete any existing param/return/overload tags
|
@@ -123,6 +123,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
123
123
|
|
124
124
|
# If there's only one overload, move the tags to the object itself
|
125
125
|
return unless overloads.length == 1
|
126
|
+
|
126
127
|
overload = overloads.first
|
127
128
|
object.parameters = overload.parameters
|
128
129
|
object.add_tag(*overload.tags)
|
@@ -184,7 +185,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
184
185
|
node_as_string(parameters[0]),
|
185
186
|
nil, # TODO: determine default from corresponding Ruby method signature?
|
186
187
|
method_name.include?('optional'),
|
187
|
-
method_name.include?('repeated')
|
188
|
+
method_name.include?('repeated')
|
188
189
|
)
|
189
190
|
end
|
190
191
|
|
@@ -215,7 +216,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
215
216
|
nil, # TODO: determine default from corresponding Ruby method signature?
|
216
217
|
block.method_name.source.include?('optional'),
|
217
218
|
false, # Not repeated
|
218
|
-
true
|
219
|
+
true # Is block
|
219
220
|
)
|
220
221
|
end
|
221
222
|
end
|
@@ -243,7 +244,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
243
244
|
param_tags,
|
244
245
|
parameter.source,
|
245
246
|
parameter.file,
|
246
|
-
parameter.line
|
247
|
+
parameter.line
|
247
248
|
)
|
248
249
|
end
|
249
250
|
|
@@ -258,7 +259,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
258
259
|
parameter.line,
|
259
260
|
nil,
|
260
261
|
parameter[1].source,
|
261
|
-
true
|
262
|
+
true
|
262
263
|
)
|
263
264
|
end
|
264
265
|
|
@@ -274,7 +275,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
274
275
|
nil,
|
275
276
|
nil,
|
276
277
|
false,
|
277
|
-
true
|
278
|
+
true
|
278
279
|
)
|
279
280
|
end
|
280
281
|
|
@@ -291,7 +292,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
291
292
|
nil,
|
292
293
|
false,
|
293
294
|
false,
|
294
|
-
true
|
295
|
+
true
|
295
296
|
)
|
296
297
|
end
|
297
298
|
|
@@ -309,15 +310,15 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
309
310
|
log.warn "Missing @param tag for parameter '#{name}' near #{file}:#{line}." unless tag || object.docstring.all.empty?
|
310
311
|
|
311
312
|
if type && tag && tag.types && !tag.types.empty?
|
312
|
-
log.warn "The @param tag for parameter '#{name}' should not contain a "\
|
313
|
-
|
314
|
-
|
313
|
+
log.warn "The @param tag for parameter '#{name}' should not contain a " \
|
314
|
+
"type specification near #{file}:#{line}: ignoring in favor of " \
|
315
|
+
'dispatch type information.'
|
315
316
|
end
|
316
317
|
|
317
318
|
if repeated
|
318
|
-
name =
|
319
|
+
name = "*#{name}"
|
319
320
|
elsif block
|
320
|
-
name =
|
321
|
+
name = "&#{name}"
|
321
322
|
end
|
322
323
|
|
323
324
|
type ||= tag&.types ? tag.type : 'Any'
|
@@ -94,7 +94,7 @@ class PuppetStrings::Yard::Handlers::Ruby::ProviderHandler < PuppetStrings::Yard
|
|
94
94
|
|
95
95
|
object.add_confine(node_as_string(kvp[0]) || kvp[0].source, node_as_string(kvp[1]) || kvp[1].source)
|
96
96
|
end
|
97
|
-
elsif [
|
97
|
+
elsif %w[has_feature has_features].include?(method_name)
|
98
98
|
# Add the features to the object
|
99
99
|
parameters.each do |parameter|
|
100
100
|
object.add_feature(node_as_string(parameter) || parameter.source)
|
@@ -53,9 +53,9 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H
|
|
53
53
|
# check that the params of the register_type call are key/value pairs.
|
54
54
|
def kv_arg_list?(params)
|
55
55
|
params.type == :list &&
|
56
|
-
params.children.count
|
56
|
+
params.children.count.positive? &&
|
57
57
|
params.children.first.type == :list &&
|
58
|
-
params.children.first.children.count
|
58
|
+
params.children.first.children.count.positive? &&
|
59
59
|
statement.parameters.children.first.children.first.type == :assoc
|
60
60
|
end
|
61
61
|
|
@@ -101,7 +101,7 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H
|
|
101
101
|
kv_pairs = node.children.map do |assoc|
|
102
102
|
[value_from_node(assoc.children[0]), value_from_node(assoc.children[1])]
|
103
103
|
end
|
104
|
-
|
104
|
+
kv_pairs.to_h
|
105
105
|
end
|
106
106
|
|
107
107
|
def var_ref_from_node(node)
|
@@ -129,7 +129,7 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H
|
|
129
129
|
|
130
130
|
schema['attributes'].each do |name, definition|
|
131
131
|
# puts "Processing #{name}: #{definition.inspect}"
|
132
|
-
if [
|
132
|
+
if %w[parameter namevar].include? definition['behaviour']
|
133
133
|
object.add_parameter(create_parameter(name, definition))
|
134
134
|
else
|
135
135
|
object.add_property(create_property(name, definition))
|
@@ -110,15 +110,18 @@ class PuppetStrings::Yard::Handlers::Ruby::TypeBase < PuppetStrings::Yard::Handl
|
|
110
110
|
return unless object.is_a? PuppetStrings::Yard::CodeObjects::Type::Parameter
|
111
111
|
# Process the options for parameter base types
|
112
112
|
return unless parameters.count >= 2
|
113
|
+
|
113
114
|
parameters[1].each do |kvp|
|
114
115
|
next unless kvp.count == 2
|
115
116
|
next unless node_as_string(kvp[0]) == 'parent'
|
116
117
|
|
117
118
|
if kvp[1].source == 'Puppet::Parameter::Boolean'
|
119
|
+
# rubocop:disable Performance/InefficientHashSearch
|
118
120
|
object.add('true') unless object.values.include? 'true'
|
119
121
|
object.add('false') unless object.values.include? 'false'
|
120
122
|
object.add('yes') unless object.values.include? 'yes'
|
121
123
|
object.add('no') unless object.values.include? 'no'
|
124
|
+
# rubocop:enable Performance/InefficientHashSearch
|
122
125
|
end
|
123
126
|
break
|
124
127
|
end
|
@@ -52,7 +52,8 @@ class PuppetStrings::Yard::Handlers::Ruby::TypeHandler < PuppetStrings::Yard::Ha
|
|
52
52
|
method_name = node.method_name.source
|
53
53
|
parameters = node.parameters(false)
|
54
54
|
|
55
|
-
|
55
|
+
case method_name
|
56
|
+
when 'newproperty'
|
56
57
|
# Add a property to the object
|
57
58
|
next unless parameters.count >= 1
|
58
59
|
|
@@ -60,7 +61,7 @@ class PuppetStrings::Yard::Handlers::Ruby::TypeHandler < PuppetStrings::Yard::Ha
|
|
60
61
|
next unless name
|
61
62
|
|
62
63
|
object.add_property(create_property(name, node))
|
63
|
-
|
64
|
+
when 'newparam'
|
64
65
|
# Add a parameter to the object
|
65
66
|
next unless parameters.count >= 1
|
66
67
|
|
@@ -68,7 +69,7 @@ class PuppetStrings::Yard::Handlers::Ruby::TypeHandler < PuppetStrings::Yard::Ha
|
|
68
69
|
next unless name
|
69
70
|
|
70
71
|
object.add_parameter(create_parameter(name, node))
|
71
|
-
|
72
|
+
when 'newcheck'
|
72
73
|
# Add a check to the object
|
73
74
|
next unless parameters.count >= 1
|
74
75
|
|
@@ -76,7 +77,7 @@ class PuppetStrings::Yard::Handlers::Ruby::TypeHandler < PuppetStrings::Yard::Ha
|
|
76
77
|
next unless name
|
77
78
|
|
78
79
|
object.add_check(create_check(name, node))
|
79
|
-
|
80
|
+
when 'feature'
|
80
81
|
# Add a feature to the object
|
81
82
|
next unless parameters.count >= 2
|
82
83
|
|
@@ -87,7 +88,7 @@ class PuppetStrings::Yard::Handlers::Ruby::TypeHandler < PuppetStrings::Yard::Ha
|
|
87
88
|
next unless docstring
|
88
89
|
|
89
90
|
object.add_feature(PuppetStrings::Yard::CodeObjects::Type::Feature.new(name, docstring))
|
90
|
-
|
91
|
+
when 'ensurable'
|
91
92
|
if node.block
|
92
93
|
property = create_property('ensure', node)
|
93
94
|
property.docstring = DEFAULT_ENSURABLE_DOCSTRING if property.docstring.empty?
|
@@ -28,7 +28,7 @@ class PuppetStrings::Yard::Parsers::JSON::Parser < YARD::Parser::Base
|
|
28
28
|
# TODO: this should compare json to a Task metadata json-schema or perform some other hueristics
|
29
29
|
# to determine what type of statement it represents
|
30
30
|
@statements.push(PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, @source, @file)) unless json.empty?
|
31
|
-
rescue
|
31
|
+
rescue StandardError
|
32
32
|
log.error "Failed to parse #{@file}: "
|
33
33
|
@statements = []
|
34
34
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Naming/MethodName
|
4
|
-
|
5
3
|
require 'puppet'
|
6
4
|
require 'puppet/pops'
|
7
5
|
require 'puppet-strings/yard/parsers/puppet/statement'
|
@@ -24,10 +22,6 @@ class PuppetStrings::Yard::Parsers::Puppet::Parser < YARD::Parser::Base
|
|
24
22
|
# @return [void]
|
25
23
|
def parse
|
26
24
|
begin
|
27
|
-
if @file.to_s.match?(%r{^plans|/plans/}) && Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') < 0
|
28
|
-
log.warn "Skipping #{@file}: Puppet Plans require Puppet 5 or greater."
|
29
|
-
return
|
30
|
-
end
|
31
25
|
Puppet[:tasks] = true if Puppet.settings.include?(:tasks)
|
32
26
|
@statements ||= (@visitor.visit(::Puppet::Pops::Parser::Parser.new.parse_string(source)) || []).compact
|
33
27
|
rescue ::Puppet::ParseError => e
|
@@ -7,13 +7,9 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
7
7
|
# Represents the base Puppet language statement.
|
8
8
|
class Statement
|
9
9
|
# The pattern for parsing docstring comments.
|
10
|
-
COMMENT_REGEX =
|
10
|
+
COMMENT_REGEX = /^\s*#+\s?/.freeze
|
11
11
|
|
12
|
-
attr_reader :source
|
13
|
-
attr_reader :file
|
14
|
-
attr_reader :line
|
15
|
-
attr_reader :docstring
|
16
|
-
attr_reader :comments_range
|
12
|
+
attr_reader :source, :file, :line, :docstring, :comments_range
|
17
13
|
|
18
14
|
# Initializes the Puppet language statement.
|
19
15
|
# @param object The Puppet parser model object for the statement.
|
@@ -67,7 +63,7 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
67
63
|
private
|
68
64
|
|
69
65
|
def first_line
|
70
|
-
@source.split(
|
66
|
+
@source.split(/\r?\n/).first.strip
|
71
67
|
end
|
72
68
|
end
|
73
69
|
|
@@ -75,20 +71,17 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
75
71
|
class ParameterizedStatement < Statement
|
76
72
|
# Implements a parameter for a parameterized statement.
|
77
73
|
class Parameter
|
78
|
-
attr_reader :name
|
79
|
-
attr_reader :type
|
80
|
-
attr_reader :value
|
74
|
+
attr_reader :name, :type, :value
|
81
75
|
|
82
76
|
# Initializes the parameter.
|
83
77
|
# @param [Puppet::Pops::Model::Parameter] parameter The parameter model object.
|
84
78
|
def initialize(parameter)
|
85
79
|
@name = parameter.name
|
86
80
|
# Take the exact text for the type expression
|
87
|
-
if parameter.type_expr
|
88
|
-
@type = PuppetStrings::Yard::Util.ast_to_text(parameter.type_expr)
|
89
|
-
end
|
81
|
+
@type = PuppetStrings::Yard::Util.ast_to_text(parameter.type_expr) if parameter.type_expr
|
90
82
|
# Take the exact text for the default value expression
|
91
83
|
return unless parameter.value
|
84
|
+
|
92
85
|
@value = PuppetStrings::Yard::Util.ast_to_text(parameter.value)
|
93
86
|
end
|
94
87
|
end
|
@@ -106,8 +99,7 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
106
99
|
|
107
100
|
# Implements the Puppet class statement.
|
108
101
|
class ClassStatement < ParameterizedStatement
|
109
|
-
attr_reader :name
|
110
|
-
attr_reader :parent_class
|
102
|
+
attr_reader :name, :parent_class
|
111
103
|
|
112
104
|
# Initializes the Puppet class statement.
|
113
105
|
# @param [Puppet::Pops::Model::HostClassDefinition] object The model object for the class statement.
|
@@ -134,8 +126,7 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
134
126
|
|
135
127
|
# Implements the Puppet function statement.
|
136
128
|
class FunctionStatement < ParameterizedStatement
|
137
|
-
attr_reader :name
|
138
|
-
attr_reader :type
|
129
|
+
attr_reader :name, :type
|
139
130
|
|
140
131
|
# Initializes the Puppet function statement.
|
141
132
|
# @param [Puppet::Pops::Model::FunctionDefinition] object The model object for the function statement.
|
@@ -144,8 +135,10 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
144
135
|
super(object, file)
|
145
136
|
@name = object.name
|
146
137
|
return unless object.respond_to? :return_type
|
138
|
+
|
147
139
|
type = object.return_type
|
148
140
|
return unless type
|
141
|
+
|
149
142
|
@type = PuppetStrings::Yard::Util.ast_to_text(type).gsub('>> ', '')
|
150
143
|
end
|
151
144
|
end
|
@@ -165,8 +158,7 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
165
158
|
|
166
159
|
# Implements the Puppet data type alias statement.
|
167
160
|
class DataTypeAliasStatement < Statement
|
168
|
-
attr_reader :name
|
169
|
-
attr_reader :alias_of
|
161
|
+
attr_reader :name, :alias_of
|
170
162
|
|
171
163
|
# Initializes the Puppet data type alias statement.
|
172
164
|
# @param [Puppet::Pops::Model::TypeAlias] object The model object for the type statement.
|
@@ -178,7 +170,7 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
178
170
|
case type_expr
|
179
171
|
when Puppet::Pops::Model::AccessExpression
|
180
172
|
# TODO: I don't like rebuilding the source from the AST, but AccessExpressions don't expose the original source
|
181
|
-
@alias_of = PuppetStrings::Yard::Util.ast_to_text(type_expr.left_expr) +
|
173
|
+
@alias_of = +"#{PuppetStrings::Yard::Util.ast_to_text(type_expr.left_expr)}[" # alias_of should be mutable so we add a + to the string.
|
182
174
|
@alias_of << type_expr.keys.map { |key| PuppetStrings::Yard::Util.ast_to_text(key) }.join(', ')
|
183
175
|
@alias_of << ']'
|
184
176
|
else
|
@@ -21,16 +21,16 @@ class PuppetStrings::Yard::Tags::OverloadTag < YARD::Tags::Tag
|
|
21
21
|
# @return [String] Returns the signature of the overload.
|
22
22
|
def signature
|
23
23
|
tags = self.tags(:param)
|
24
|
-
args = @parameters.map
|
24
|
+
args = @parameters.map do |parameter|
|
25
25
|
name, default = parameter
|
26
26
|
tag = tags.find { |t| t.name == name } if tags
|
27
27
|
type = tag&.types ? "#{tag.type} " : 'Any '
|
28
28
|
prefix = (name[0]).to_s if name.start_with?('*', '&')
|
29
|
-
name = name[1
|
29
|
+
name = name[1..] if prefix
|
30
30
|
default = " = #{default}" if default
|
31
31
|
"#{type}#{prefix}$#{name}#{default}"
|
32
|
-
|
33
|
-
@name
|
32
|
+
end.join(', ')
|
33
|
+
"#{@name}(#{args})"
|
34
34
|
end
|
35
35
|
|
36
36
|
# Adds a tag to the overload's docstring.
|
@@ -7,7 +7,7 @@ class PuppetStrings::Yard::Tags::ParameterDirective < YARD::Tags::Directive
|
|
7
7
|
# Called to invoke the directive.
|
8
8
|
# @return [void]
|
9
9
|
def call
|
10
|
-
return unless object
|
10
|
+
return unless object.respond_to?(:add_parameter)
|
11
11
|
|
12
12
|
# Add a parameter to the resource
|
13
13
|
parameter = PuppetStrings::Yard::CodeObjects::Type::Parameter.new(tag.name, tag.text)
|
@@ -7,7 +7,7 @@ class PuppetStrings::Yard::Tags::PropertyDirective < YARD::Tags::Directive
|
|
7
7
|
# Called to invoke the directive.
|
8
8
|
# @return [void]
|
9
9
|
def call
|
10
|
-
return unless object
|
10
|
+
return unless object.respond_to?(:add_property)
|
11
11
|
|
12
12
|
# Add a property to the resource
|
13
13
|
property = PuppetStrings::Yard::CodeObjects::Type::Property.new(tag.name, tag.text)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Generates the searchable Puppet class list.
|
2
4
|
# @return [void]
|
3
5
|
def generate_puppet_class_list
|
@@ -10,7 +12,7 @@ end
|
|
10
12
|
# Generates the searchable Puppet data type list.
|
11
13
|
# @return [void]
|
12
14
|
def generate_puppet_data_type_list
|
13
|
-
@items = Registry.all(:puppet_data_type, :puppet_data_type_alias).sort_by {|dt| dt.name.to_s }
|
15
|
+
@items = Registry.all(:puppet_data_type, :puppet_data_type_alias).sort_by { |dt| dt.name.to_s }
|
14
16
|
@list_title = 'Data Type List'
|
15
17
|
@list_type = 'puppet_data_type'
|
16
18
|
generate_list_contents
|
@@ -19,7 +21,7 @@ end
|
|
19
21
|
# Generates the searchable Puppet defined type list.
|
20
22
|
# @return [void]
|
21
23
|
def generate_puppet_defined_type_list
|
22
|
-
@items = Registry.all(:puppet_defined_type).sort_by {|dt| dt.name.to_s }
|
24
|
+
@items = Registry.all(:puppet_defined_type).sort_by { |dt| dt.name.to_s }
|
23
25
|
@list_title = 'Defined Type List'
|
24
26
|
@list_type = 'puppet_defined_type'
|
25
27
|
generate_list_contents
|
@@ -28,7 +30,7 @@ end
|
|
28
30
|
# Generates the searchable Puppet resource type list.
|
29
31
|
# @return [void]
|
30
32
|
def generate_puppet_type_list
|
31
|
-
@items = Registry.all(:puppet_type).sort_by {|t| t.name.to_s }
|
33
|
+
@items = Registry.all(:puppet_type).sort_by { |t| t.name.to_s }
|
32
34
|
@list_title = 'Resource Type List'
|
33
35
|
@list_type = 'puppet_type'
|
34
36
|
generate_list_contents
|
@@ -37,7 +39,7 @@ end
|
|
37
39
|
# Generates the searchable Puppet provider list.
|
38
40
|
# @return [void]
|
39
41
|
def generate_puppet_provider_list
|
40
|
-
@items = Registry.all(:puppet_provider).sort_by {|p| p.name.to_s }
|
42
|
+
@items = Registry.all(:puppet_provider).sort_by { |p| p.name.to_s }
|
41
43
|
@list_title = 'Provider List'
|
42
44
|
@list_type = 'puppet_provider'
|
43
45
|
generate_list_contents
|
@@ -46,7 +48,7 @@ end
|
|
46
48
|
# Generates the searchable Puppet function list.
|
47
49
|
# @return [void]
|
48
50
|
def generate_puppet_function_list
|
49
|
-
@items = Registry.all(:puppet_function).sort_by {|f| f.name.to_s }
|
51
|
+
@items = Registry.all(:puppet_function).sort_by { |f| f.name.to_s }
|
50
52
|
@list_title = 'Puppet Function List'
|
51
53
|
@list_type = 'puppet_function'
|
52
54
|
generate_list_contents
|
@@ -56,8 +58,8 @@ end
|
|
56
58
|
# @return [void]
|
57
59
|
def generate_method_list
|
58
60
|
@items = prune_method_listing(Registry.all(:method), false)
|
59
|
-
@items = @items.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? }
|
60
|
-
@items = @items.sort_by {|m| m.name.to_s }
|
61
|
+
@items = @items.reject { |m| m.name.to_s =~ /=$/ && m.is_attribute? }
|
62
|
+
@items = @items.sort_by { |m| m.name.to_s }
|
61
63
|
@list_title = 'Ruby Method List'
|
62
64
|
@list_type = 'method'
|
63
65
|
generate_list_contents
|
@@ -75,7 +77,7 @@ end
|
|
75
77
|
# Generates the searchable Puppet Task list.
|
76
78
|
# @return [void]
|
77
79
|
def generate_puppet_task_list
|
78
|
-
@items = Registry.all(:puppet_task).sort_by {|t| t.name.to_s }
|
80
|
+
@items = Registry.all(:puppet_task).sort_by { |t| t.name.to_s }
|
79
81
|
@list_title = 'Puppet Task List'
|
80
82
|
@list_type = 'puppet_task'
|
81
83
|
generate_list_contents
|
@@ -84,7 +86,7 @@ end
|
|
84
86
|
# Generates the searchable Puppet Plan list.
|
85
87
|
# @return [void]
|
86
88
|
def generate_puppet_plan_list
|
87
|
-
@items = Registry.all(:puppet_plan).sort_by {|t| t.name.to_s }
|
89
|
+
@items = Registry.all(:puppet_plan).sort_by { |t| t.name.to_s }
|
88
90
|
@list_title = 'Puppet Plan List'
|
89
91
|
@list_type = 'puppet_plan'
|
90
92
|
generate_list_contents
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Initializes the template.
|
2
4
|
# @return [void]
|
3
5
|
def init
|
4
6
|
case object
|
5
7
|
when '_index.html'
|
6
8
|
@page_title = options.title
|
7
|
-
sections :layout, [:index, [:listing, [
|
9
|
+
sections :layout, [:index, [:listing, %i[classes data_types defined_types types providers functions tasks plans files objects]]]
|
8
10
|
else
|
9
11
|
super
|
10
12
|
end
|
@@ -64,9 +66,7 @@ def layout
|
|
64
66
|
|
65
67
|
final_layout = erb(:layout)
|
66
68
|
|
67
|
-
if @file && @file.name == 'README'
|
68
|
-
PuppetStrings::Yard::Util.github_to_yard_links(final_layout)
|
69
|
-
end
|
69
|
+
PuppetStrings::Yard::Util.github_to_yard_links(final_layout) if @file && @file.name == 'README'
|
70
70
|
|
71
71
|
final_layout
|
72
72
|
end
|
@@ -83,12 +83,12 @@ def create_menu_lists
|
|
83
83
|
{
|
84
84
|
type: 'puppet_data_type',
|
85
85
|
title: 'Data Types',
|
86
|
-
search_title: 'Data Types'
|
86
|
+
search_title: 'Data Types'
|
87
87
|
},
|
88
88
|
{
|
89
89
|
type: 'puppet_defined_type',
|
90
90
|
title: 'Defined Types',
|
91
|
-
search_title: 'Defined Types'
|
91
|
+
search_title: 'Defined Types'
|
92
92
|
},
|
93
93
|
{
|
94
94
|
type: 'puppet_type',
|
@@ -124,17 +124,19 @@ def create_menu_lists
|
|
124
124
|
type: 'method',
|
125
125
|
title: 'Ruby Methods',
|
126
126
|
search_title: 'Method List'
|
127
|
-
}
|
127
|
+
}
|
128
128
|
]
|
129
129
|
|
130
130
|
menu_lists.delete_if { |e| YARD::Registry.all(e[:type].intern).empty? }
|
131
131
|
|
132
132
|
# We must always return at least one group, so always keep the files list
|
133
|
-
menu_lists
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
133
|
+
if menu_lists.empty? || !YARD::Registry.all(:file).empty?
|
134
|
+
menu_lists << {
|
135
|
+
type: 'file',
|
136
|
+
title: 'Files',
|
137
|
+
search_title: 'File List'
|
138
|
+
}
|
139
|
+
end
|
138
140
|
|
139
141
|
menu_lists
|
140
142
|
end
|
@@ -150,9 +152,9 @@ end
|
|
150
152
|
# @return [Hash] Returns a hash of first letter of the object name to list of objects.
|
151
153
|
def objects_by_letter(*types)
|
152
154
|
hash = {}
|
153
|
-
objects = Registry.all(*types).sort_by {|o| o.name.to_s }
|
155
|
+
objects = Registry.all(*types).sort_by { |o| o.name.to_s }
|
154
156
|
objects = run_verifier(objects)
|
155
|
-
objects.each {|o| (hash[o.name.to_s[0,1].upcase] ||= []) << o }
|
157
|
+
objects.each { |o| (hash[o.name.to_s[0, 1].upcase] ||= []) << o }
|
156
158
|
hash
|
157
159
|
end
|
158
160
|
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Initializes the template.
|
2
4
|
# @return [void]
|
3
5
|
def init
|
4
|
-
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
|
6
|
+
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :source
|
5
7
|
end
|
6
8
|
|
7
9
|
# Renders the box_info section.
|
8
10
|
# @return [String] Returns the rendered section.
|
9
11
|
def box_info
|
10
|
-
@subclasses = Registry.all(:puppet_class).find_all
|
12
|
+
@subclasses = Registry.all(:puppet_class).find_all do |c|
|
11
13
|
c.statement.parent_class == object.name.to_s
|
12
|
-
|
14
|
+
end
|
13
15
|
erb(:box_info)
|
14
16
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Initializes the template.
|
2
4
|
# @return [void]
|
3
5
|
def init
|
4
|
-
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :method_details_list, [T('method_details')], :source
|
6
|
+
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :method_details_list, [T('method_details')], :source
|
5
7
|
end
|
6
8
|
|
7
9
|
def method_listing
|
@@ -9,5 +11,5 @@ def method_listing
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def sort_listing(list)
|
12
|
-
list.sort_by {|o| [o.scope.to_s, o.name.to_s.downcase] }
|
14
|
+
list.sort_by { |o| [o.scope.to_s, o.name.to_s.downcase] }
|
13
15
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Initializes the template.
|
2
4
|
# @return [void]
|
3
5
|
def init
|
4
|
-
sections :header, :box_info, :summary, :overview, :alias_of, :note, :todo, T('tags'), :source
|
6
|
+
sections :header, :box_info, :summary, :overview, :alias_of, :note, :todo, :deprecated, T('tags'), :source
|
5
7
|
end
|
6
8
|
|
7
9
|
# Renders the alias_of section.
|
@@ -9,8 +11,8 @@ end
|
|
9
11
|
def alias_of
|
10
12
|
# Properties are the same thing as parameters (from the documentation standpoint),
|
11
13
|
# so reuse the same template but with a different title and data source.
|
12
|
-
|
13
|
-
|
14
|
+
# @parameters = object.properties || []
|
15
|
+
# @parameters.sort_by! { |p| p.name }
|
14
16
|
@tag_title = 'Alias of'
|
15
17
|
@alias_of = object.alias_of
|
16
18
|
erb(:alias_of)
|