puppet-strings 3.0.1 → 4.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -20,6 +20,7 @@ module PuppetStrings::Markdown
|
|
20
20
|
# [{:tag_name=>"summary", :text=>"A simple class."},
|
21
21
|
# {:tag_name=>"since", :text=>"1.0.0"},
|
22
22
|
# {:tag_name=>"see", :name=>"www.puppet.com"},
|
23
|
+
# {:tag_name=>"deprecated", :text=>"No longer supported and will be removed in a future release"},
|
23
24
|
# {:tag_name=>"example",
|
24
25
|
# :text=>
|
25
26
|
# "class { 'klass':\n" +
|
@@ -93,7 +94,8 @@ module PuppetStrings::Markdown
|
|
93
94
|
since: 'since',
|
94
95
|
summary: 'summary',
|
95
96
|
note: 'note',
|
96
|
-
todo: 'todo'
|
97
|
+
todo: 'todo',
|
98
|
+
deprecated: 'deprecated' }.each do |method_name, tag_name|
|
97
99
|
# @return [String] unless the tag is nil or the string.empty?
|
98
100
|
define_method method_name do
|
99
101
|
@tags.find { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }[:text] if @tags.any? { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }
|
@@ -159,7 +161,7 @@ module PuppetStrings::Markdown
|
|
159
161
|
# @return [Array] option tag hashes that have a parent parameter_name
|
160
162
|
def options_for_param(parameter_name)
|
161
163
|
opts_for_p = options.select { |o| o[:parent] == parameter_name } unless options.nil?
|
162
|
-
opts_for_p unless opts_for_p.nil? || opts_for_p.
|
164
|
+
opts_for_p unless opts_for_p.nil? || opts_for_p.empty?
|
163
165
|
end
|
164
166
|
|
165
167
|
# @param parameter_name
|
@@ -167,7 +169,7 @@ module PuppetStrings::Markdown
|
|
167
169
|
# @return [Array] enum tag hashes that have a parent parameter_name
|
168
170
|
def enums_for_param(parameter_name)
|
169
171
|
enums_for_p = enums.select { |e| e[:parent] == parameter_name } unless enums.nil?
|
170
|
-
enums_for_p unless enums_for_p.nil? || enums_for_p.
|
172
|
+
enums_for_p unless enums_for_p.nil? || enums_for_p.empty?
|
171
173
|
end
|
172
174
|
|
173
175
|
# @return [Hash] any defaults found for the component
|
@@ -198,7 +200,7 @@ module PuppetStrings::Markdown
|
|
198
200
|
return unless text
|
199
201
|
|
200
202
|
text.split("\n").map! { |line|
|
201
|
-
line.length > line_width ? line.gsub(
|
203
|
+
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1#{break_sequence}").strip : line
|
202
204
|
} * break_sequence
|
203
205
|
end
|
204
206
|
|
@@ -5,17 +5,16 @@ require 'puppet-strings/markdown/base'
|
|
5
5
|
module PuppetStrings::Markdown
|
6
6
|
# This class encapsualtes ruby data types and puppet type aliases
|
7
7
|
class DataType < Base
|
8
|
-
attr_reader :alias_of
|
9
|
-
attr_reader :functions
|
8
|
+
attr_reader :alias_of, :functions
|
10
9
|
|
11
10
|
group_name 'Data types'
|
12
|
-
yard_types [
|
11
|
+
yard_types %i[puppet_data_type puppet_data_type_alias]
|
13
12
|
|
14
13
|
def initialize(registry)
|
15
14
|
@template = 'data_type.erb'
|
16
15
|
super(registry, 'data type')
|
17
16
|
@alias_of = registry[:alias_of] unless registry[:alias_of].nil?
|
18
|
-
@functions = @registry[:functions]
|
17
|
+
@functions = @registry[:functions]&.map { |func| DataType::Function.new(func) }
|
19
18
|
end
|
20
19
|
|
21
20
|
def render
|
@@ -25,11 +25,11 @@ module PuppetStrings::Markdown
|
|
25
25
|
|
26
26
|
def type
|
27
27
|
t = @registry[:type]
|
28
|
-
if
|
28
|
+
if t.include?('ruby4x')
|
29
29
|
'Ruby 4.x API'
|
30
|
-
elsif
|
30
|
+
elsif t.include?('ruby3')
|
31
31
|
'Ruby 3.x API'
|
32
|
-
elsif
|
32
|
+
elsif t.include?('ruby')
|
33
33
|
'Ruby'
|
34
34
|
else
|
35
35
|
'Puppet Language'
|
@@ -37,11 +37,11 @@ module PuppetStrings::Markdown
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def error_type(type)
|
40
|
-
"`#{type.split
|
40
|
+
"`#{type.split[0]}`"
|
41
41
|
end
|
42
42
|
|
43
43
|
def error_text(text)
|
44
|
-
text.split
|
44
|
+
text.split.drop(1).join(' ').to_s
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -23,7 +23,7 @@ module PuppetStrings::Markdown
|
|
23
23
|
PuppetStrings::Markdown::Function,
|
24
24
|
PuppetStrings::Markdown::DataType,
|
25
25
|
PuppetStrings::Markdown::PuppetTask,
|
26
|
-
PuppetStrings::Markdown::PuppetPlan
|
26
|
+
PuppetStrings::Markdown::PuppetPlan
|
27
27
|
]
|
28
28
|
end
|
29
29
|
|
@@ -33,14 +33,14 @@ module PuppetStrings::Markdown
|
|
33
33
|
output = [
|
34
34
|
"# Reference\n\n",
|
35
35
|
"<!-- DO NOT EDIT: This document was generated by Puppet Strings -->\n\n",
|
36
|
-
"## Table of Contents\n\n"
|
36
|
+
"## Table of Contents\n\n"
|
37
37
|
]
|
38
38
|
|
39
39
|
# Create table of contents
|
40
40
|
template = erb(File.join(__dir__, 'markdown', 'templates', 'table_of_contents.erb'))
|
41
41
|
groups.each do |group|
|
42
42
|
group_name = group.group_name
|
43
|
-
items = group.items.map
|
43
|
+
items = group.items.map(&:toc_info)
|
44
44
|
has_private = items.any? { |item| item[:private] }
|
45
45
|
has_public = items.any? { |item| !item[:private] }
|
46
46
|
|
@@ -49,14 +49,14 @@ module PuppetStrings::Markdown
|
|
49
49
|
|
50
50
|
# Create actual contents
|
51
51
|
groups.each do |group|
|
52
|
-
items = group.items.reject
|
52
|
+
items = group.items.reject(&:private?)
|
53
53
|
unless items.empty?
|
54
54
|
output << "## #{group.group_name}\n\n"
|
55
|
-
output.append(items.map
|
55
|
+
output.append(items.map(&:render))
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
output.join
|
59
|
+
output.join
|
60
60
|
end
|
61
61
|
|
62
62
|
# mimicks the behavior of the json render, although path will never be nil
|
@@ -66,7 +66,7 @@ module PuppetStrings::Markdown
|
|
66
66
|
puts generate
|
67
67
|
exit
|
68
68
|
else
|
69
|
-
File.
|
69
|
+
File.write(path, generate)
|
70
70
|
YARD::Logger.instance.debug "Wrote markdown to #{path}"
|
71
71
|
end
|
72
72
|
end
|
@@ -76,11 +76,9 @@ module PuppetStrings::Markdown
|
|
76
76
|
# @param [String] path The full path to the template file.
|
77
77
|
# @return [ERB] Template
|
78
78
|
def self.erb(path)
|
79
|
-
|
80
|
-
ERB.new(File.read(path), trim_mode: '-')
|
81
|
-
else
|
79
|
+
unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
|
82
80
|
# This outputs warnings in Ruby 2.6+.
|
83
|
-
ERB.new(File.read(path), nil, '-')
|
84
81
|
end
|
82
|
+
ERB.new(File.read(path), trim_mode: '-')
|
85
83
|
end
|
86
84
|
end
|
@@ -13,7 +13,7 @@ namespace :strings do
|
|
13
13
|
options = {
|
14
14
|
debug: args[:debug] == 'true',
|
15
15
|
backtrace: args[:backtrace] == 'true',
|
16
|
-
markup: args[:markup] || 'markdown'
|
16
|
+
markup: args[:markup] || 'markdown'
|
17
17
|
}
|
18
18
|
|
19
19
|
raise('Error: Both JSON and Markdown output have been selected. Please select one.') if args[:json] == 'true' && args[:markdown] == 'true'
|
@@ -29,13 +29,15 @@ namespace :strings do
|
|
29
29
|
# @return nil
|
30
30
|
def parse_format_option(args, options, format)
|
31
31
|
return unless args.has_key? format
|
32
|
-
|
32
|
+
|
33
|
+
options[format] = !(args[format] == 'false' || args[format].empty?)
|
33
34
|
return unless options[format]
|
35
|
+
|
34
36
|
options[:path] = args[format] == 'true' ? nil : args[format]
|
35
37
|
end
|
36
38
|
# rubocop:enable Style/PreferredHashMethods
|
37
39
|
|
38
|
-
[
|
40
|
+
%i[json markdown].each { |format| parse_format_option(args, options, format) }
|
39
41
|
|
40
42
|
warn('yard_args behavior is a little dodgy, use at your own risk') if args[:yard_args]
|
41
43
|
options[:yard_args] = args[:yard_args].split if args.key? :yard_args
|
@@ -30,7 +30,7 @@ namespace :strings do
|
|
30
30
|
task :configure do
|
31
31
|
unless File.exist?(File.join('doc', '_config.yml'))
|
32
32
|
Dir.chdir('doc') do
|
33
|
-
File.
|
33
|
+
File.write('_config.yml', 'include: _index.html')
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -48,11 +48,11 @@ namespace :strings do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
desc 'Update docs on the gh-pages branch and push to GitHub.'
|
51
|
-
task update: [
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
task update: %i[
|
52
|
+
checkout
|
53
|
+
strings:generate
|
54
|
+
configure
|
55
|
+
push
|
56
56
|
]
|
57
57
|
end
|
58
58
|
end
|
@@ -10,7 +10,7 @@ namespace :strings do
|
|
10
10
|
filename = 'REFERENCE.md'
|
11
11
|
|
12
12
|
unless File.exist?(filename)
|
13
|
-
|
13
|
+
warn "#{filename} does not exist"
|
14
14
|
exit 1
|
15
15
|
end
|
16
16
|
|
@@ -24,7 +24,7 @@ namespace :strings do
|
|
24
24
|
backtrace: args[:backtrace] == 'true',
|
25
25
|
json: false,
|
26
26
|
markdown: true,
|
27
|
-
path: file
|
27
|
+
path: file
|
28
28
|
}
|
29
29
|
PuppetStrings.generate(patterns, options)
|
30
30
|
|
@@ -34,7 +34,7 @@ namespace :strings do
|
|
34
34
|
existing = File.read(filename)
|
35
35
|
|
36
36
|
if generated != existing
|
37
|
-
|
37
|
+
warn "#{filename} is outdated"
|
38
38
|
exit 1
|
39
39
|
end
|
40
40
|
end
|
data/lib/puppet-strings/tasks.rb
CHANGED
@@ -8,7 +8,7 @@ module PuppetStrings end
|
|
8
8
|
|
9
9
|
# The module for Puppet Strings rake tasks.
|
10
10
|
module PuppetStrings::Tasks
|
11
|
-
require 'puppet-strings/tasks/generate
|
12
|
-
require 'puppet-strings/tasks/gh_pages
|
13
|
-
require 'puppet-strings/tasks/validate
|
11
|
+
require 'puppet-strings/tasks/generate'
|
12
|
+
require 'puppet-strings/tasks/gh_pages'
|
13
|
+
require 'puppet-strings/tasks/validate'
|
14
14
|
end
|
@@ -7,9 +7,9 @@ class PuppetStrings::Yard::CodeObjects::Base < YARD::CodeObjects::NamespaceObjec
|
|
7
7
|
# @return Returns the code object.
|
8
8
|
def self.new(*args)
|
9
9
|
# Skip the super class' implementation because it detects :: in names and this will cause namespaces in the output we don't want
|
10
|
-
object = Object.class.instance_method(:new).
|
10
|
+
object = Object.class.instance_method(:new).bind_call(self, *args)
|
11
11
|
existing = YARD::Registry.at(object.path)
|
12
|
-
object = existing if existing
|
12
|
+
object = existing if existing.instance_of?(self)
|
13
13
|
yield(object) if block_given?
|
14
14
|
object
|
15
15
|
end
|
@@ -20,8 +20,7 @@ end
|
|
20
20
|
|
21
21
|
# Implements the Puppet class code object.
|
22
22
|
class PuppetStrings::Yard::CodeObjects::Class < PuppetStrings::Yard::CodeObjects::Base
|
23
|
-
attr_reader :statement
|
24
|
-
attr_reader :parameters
|
23
|
+
attr_reader :statement, :parameters
|
25
24
|
|
26
25
|
# Initializes a Puppet class code object.
|
27
26
|
# @param [PuppetStrings::Parsers::ClassStatement] statement The class statement that was parsed.
|
@@ -87,14 +87,14 @@ class PuppetStrings::Yard::CodeObjects::DataType < PuppetStrings::Yard::CodeObje
|
|
87
87
|
hash[:name] = name
|
88
88
|
hash[:file] = file
|
89
89
|
hash[:line] = line
|
90
|
-
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring, [
|
90
|
+
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example])
|
91
91
|
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
|
92
92
|
hash[:source] = source unless source.nil? || source.empty?
|
93
93
|
hash[:functions] = functions.map do |func|
|
94
94
|
{
|
95
95
|
name: func.name,
|
96
96
|
signature: func.signature,
|
97
|
-
docstring: PuppetStrings::Yard::Util.docstring_to_hash(func.docstring, [
|
97
|
+
docstring: PuppetStrings::Yard::Util.docstring_to_hash(func.docstring, %i[param option enum return example])
|
98
98
|
}
|
99
99
|
end
|
100
100
|
hash
|
@@ -20,8 +20,7 @@ end
|
|
20
20
|
|
21
21
|
# Implements the Puppet defined type code object.
|
22
22
|
class PuppetStrings::Yard::CodeObjects::DefinedType < PuppetStrings::Yard::CodeObjects::Base
|
23
|
-
attr_reader :statement
|
24
|
-
attr_reader :parameters
|
23
|
+
attr_reader :statement, :parameters
|
25
24
|
|
26
25
|
# Initializes a Puppet defined type code object.
|
27
26
|
# @param [PuppetStrings::Parsers::DefinedTypeStatement] statement The defined type statement that was parsed.
|
@@ -65,16 +65,16 @@ class PuppetStrings::Yard::CodeObjects::Function < PuppetStrings::Yard::CodeObje
|
|
65
65
|
return '' if has_tag? :overload
|
66
66
|
|
67
67
|
tags = self.tags(:param)
|
68
|
-
args = @parameters.map
|
68
|
+
args = @parameters.map do |parameter|
|
69
69
|
name, default = parameter
|
70
70
|
tag = tags.find { |t| t.name == name } if tags
|
71
71
|
type = tag&.types ? "#{tag.type} " : 'Any '
|
72
72
|
prefix = (name[0]).to_s if name.start_with?('*', '&')
|
73
|
-
name = name[1
|
73
|
+
name = name[1..] if prefix
|
74
74
|
default = " = #{default}" if default
|
75
75
|
"#{type}#{prefix}$#{name}#{default}"
|
76
|
-
|
77
|
-
@name
|
76
|
+
end.join(', ')
|
77
|
+
"#{@name}(#{args})"
|
78
78
|
end
|
79
79
|
|
80
80
|
# Converts the code object to a hash representation.
|
@@ -91,10 +91,10 @@ class PuppetStrings::Yard::CodeObjects::Function < PuppetStrings::Yard::CodeObje
|
|
91
91
|
if has_tag? :overload
|
92
92
|
# loop over overloads and append onto the signatures array
|
93
93
|
tags(:overload).each do |o|
|
94
|
-
hash[:signatures] << { signature: o.signature, docstring: PuppetStrings::Yard::Util.docstring_to_hash(o.docstring, [
|
94
|
+
hash[:signatures] << { signature: o.signature, docstring: PuppetStrings::Yard::Util.docstring_to_hash(o.docstring, %i[param option enum return example]) }
|
95
95
|
end
|
96
96
|
else
|
97
|
-
hash[:signatures] << { signature: signature, docstring: PuppetStrings::Yard::Util.docstring_to_hash(docstring, [
|
97
|
+
hash[:signatures] << { signature: signature, docstring: PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example]) }
|
98
98
|
end
|
99
99
|
|
100
100
|
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
|
@@ -20,8 +20,7 @@ end
|
|
20
20
|
|
21
21
|
# Implements the Puppet plan code object.
|
22
22
|
class PuppetStrings::Yard::CodeObjects::Plan < PuppetStrings::Yard::CodeObjects::Base
|
23
|
-
attr_reader :statement
|
24
|
-
attr_reader :parameters
|
23
|
+
attr_reader :statement, :parameters
|
25
24
|
|
26
25
|
# Initializes a Puppet plan code object.
|
27
26
|
# @param [PuppetStrings::Parsers::PlanStatement] statement The plan statement that was parsed.
|
@@ -158,7 +158,7 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects:
|
|
158
158
|
provider_param = Parameter.new(
|
159
159
|
'provider',
|
160
160
|
"The specific backend to use for this `#{name}` resource. You will seldom need " \
|
161
|
-
'to specify this --- Puppet will usually discover the appropriate provider for your platform.'
|
161
|
+
'to specify this --- Puppet will usually discover the appropriate provider for your platform.'
|
162
162
|
)
|
163
163
|
|
164
164
|
@parameters ||= []
|
@@ -185,11 +185,11 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects:
|
|
185
185
|
hash[:line] = line
|
186
186
|
|
187
187
|
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
|
188
|
-
hash[:properties] = properties.sort_by
|
189
|
-
hash[:parameters] = parameters.sort_by
|
190
|
-
hash[:checks] = checks.sort_by
|
191
|
-
hash[:features] = features.sort_by
|
192
|
-
hash[:providers] = providers.sort_by
|
188
|
+
hash[:properties] = properties.sort_by(&:name).map(&:to_hash) if properties && !properties.empty?
|
189
|
+
hash[:parameters] = parameters.sort_by(&:name).map(&:to_hash) if parameters && !parameters.empty?
|
190
|
+
hash[:checks] = checks.sort_by(&:name).map(&:to_hash) if checks && !checks.empty?
|
191
|
+
hash[:features] = features.sort_by(&:name).map(&:to_hash) if features && !features.empty?
|
192
|
+
hash[:providers] = providers.sort_by(&:name).map(&:to_hash) if providers && !providers.empty?
|
193
193
|
|
194
194
|
hash
|
195
195
|
end
|
@@ -4,6 +4,7 @@
|
|
4
4
|
module PuppetStrings::Yard::Handlers::Helpers
|
5
5
|
def self.validate_summary_tag(object)
|
6
6
|
return unless object.has_tag?(:summary) && object.tag(:summary).text.length > 140
|
7
|
+
|
7
8
|
log.warn "The length of the summary for #{object.type} '#{object.name}' exceeds the recommended limit of 140 characters."
|
8
9
|
end
|
9
10
|
end
|
@@ -26,6 +26,7 @@ class PuppetStrings::Yard::Handlers::JSON::TaskHandler < PuppetStrings::Yard::Ha
|
|
26
26
|
|
27
27
|
def validate_params
|
28
28
|
return if @statement.parameters.empty?
|
29
|
+
|
29
30
|
@statement.parameters.each do |param, val|
|
30
31
|
log.warn "Missing description for param '#{param}' in #{@kind}" if val['description'].nil?
|
31
32
|
end
|
@@ -37,9 +37,9 @@ class PuppetStrings::Yard::Handlers::Puppet::Base < YARD::Handlers::Base
|
|
37
37
|
|
38
38
|
# Warn if the parameter type and tag types don't match
|
39
39
|
if parameter.type && tag.types && !tag.types.empty? && parameter.type != tag.types[0]
|
40
|
-
log.warn "The type of the @param tag for parameter '#{parameter.name}' "\
|
41
|
-
|
42
|
-
|
40
|
+
log.warn "The type of the @param tag for parameter '#{parameter.name}' " \
|
41
|
+
"does not match the parameter type specification near #{statement.file}:#{statement.line}: " \
|
42
|
+
'ignoring in favor of parameter type information.'
|
43
43
|
end
|
44
44
|
|
45
45
|
if parameter.type
|
@@ -6,7 +6,7 @@ require 'ripper'
|
|
6
6
|
class PuppetStrings::Yard::Handlers::Ruby::Base < YARD::Handlers::Ruby::Base
|
7
7
|
# A regular expression for detecting the start of a Ruby heredoc.
|
8
8
|
# Note: the first character of the heredoc start may have been cut off by YARD.
|
9
|
-
HEREDOC_START =
|
9
|
+
HEREDOC_START = /^<?<[-~]?['"]?(\w+)['"]?[^\n]*\n?/.freeze
|
10
10
|
|
11
11
|
protected
|
12
12
|
|
@@ -18,7 +18,7 @@ class PuppetStrings::Yard::Handlers::Ruby::Base < YARD::Handlers::Ruby::Base
|
|
18
18
|
|
19
19
|
case node.type
|
20
20
|
when :symbol, :symbol_literal
|
21
|
-
node.source[1
|
21
|
+
node.source[1..]
|
22
22
|
when :label
|
23
23
|
node.source[0..-2]
|
24
24
|
when :dyna_symbol
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Naming/MethodName
|
4
|
-
|
5
3
|
require 'puppet-strings/yard/handlers/helpers'
|
6
4
|
require 'puppet-strings/yard/handlers/ruby/base'
|
7
5
|
require 'puppet-strings/yard/code_objects'
|
@@ -255,7 +253,7 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
|
|
255
253
|
begin
|
256
254
|
callable_type = Puppet::Pops::Types::TypeParser.singleton.parse(func_type)
|
257
255
|
if callable_type.is_a?(Puppet::Pops::Types::PCallableType)
|
258
|
-
func_hash[:param_types] = callable_type.param_types.map
|
256
|
+
func_hash[:param_types] = callable_type.param_types.map(&:to_s)
|
259
257
|
func_hash[:return_type] = callable_type.return_type.to_s
|
260
258
|
else
|
261
259
|
log.warn "The function definition for '#{key}' near #{object.file}:#{object.line} is not a Callable type"
|
@@ -360,9 +358,7 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
|
|
360
358
|
# Puppet Data Type function invocation. So instead we derive a signature from the method definition.
|
361
359
|
object.meths.each do |meth|
|
362
360
|
params = ''
|
363
|
-
unless meth.docstring.tags(:param).empty?
|
364
|
-
params += '(' + meth.docstring.tags(:param).map { |t| t.name }.join(', ') + ')'
|
365
|
-
end
|
361
|
+
params += "(#{meth.docstring.tags(:param).map(&:name).join(', ')})" unless meth.docstring.tags(:param).empty?
|
366
362
|
meth.signature = "#{object.name}.#{meth.name}" + params
|
367
363
|
end
|
368
364
|
|
@@ -379,9 +375,9 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
|
|
379
375
|
if tag.tag_name == 'param'
|
380
376
|
index += 1
|
381
377
|
if index > actual_function[:param_types].count
|
382
|
-
log.warn "The @param tag for '#{tag.name}' should not exist for function "\
|
383
|
-
|
384
|
-
|
378
|
+
log.warn "The @param tag for '#{tag.name}' should not exist for function " \
|
379
|
+
"'#{meth.name}' that is defined near #{object.file}:#{object.line}. " \
|
380
|
+
"Expected only #{actual_function[:param_types].count} parameter/s"
|
385
381
|
true
|
386
382
|
else
|
387
383
|
false
|