puppet-strings 2.5.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +90 -4
- data/COMMITTERS.md +17 -17
- data/CONTRIBUTING.md +6 -6
- data/README.md +10 -10
- data/lib/puppet/application/strings.rb +2 -0
- data/lib/puppet/face/strings.rb +4 -1
- data/lib/puppet/feature/rgen.rb +2 -0
- data/lib/puppet/feature/yard.rb +2 -0
- data/lib/puppet-strings/describe.rb +2 -0
- data/lib/puppet-strings/json.rb +2 -0
- data/lib/puppet-strings/markdown/base.rb +11 -3
- data/lib/puppet-strings/markdown/data_type.rb +2 -0
- data/lib/puppet-strings/markdown/data_types.rb +3 -1
- data/lib/puppet-strings/markdown/defined_type.rb +2 -0
- data/lib/puppet-strings/markdown/defined_types.rb +3 -1
- data/lib/puppet-strings/markdown/function.rb +9 -7
- data/lib/puppet-strings/markdown/functions.rb +3 -1
- data/lib/puppet-strings/markdown/puppet_class.rb +2 -0
- data/lib/puppet-strings/markdown/puppet_classes.rb +3 -1
- data/lib/puppet-strings/markdown/puppet_plan.rb +2 -0
- data/lib/puppet-strings/markdown/puppet_plans.rb +3 -1
- data/lib/puppet-strings/markdown/puppet_task.rb +2 -0
- data/lib/puppet-strings/markdown/puppet_tasks.rb +3 -1
- data/lib/puppet-strings/markdown/resource_type.rb +2 -0
- data/lib/puppet-strings/markdown/resource_types.rb +3 -1
- data/lib/puppet-strings/markdown/table_of_contents.rb +3 -1
- data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +7 -3
- data/lib/puppet-strings/markdown/templates/data_type.erb +12 -4
- data/lib/puppet-strings/markdown/templates/data_type_function.erb +1 -1
- data/lib/puppet-strings/markdown/templates/function.erb +1 -1
- data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
- data/lib/puppet-strings/markdown/templates/resource_type.erb +8 -2
- data/lib/puppet-strings/markdown.rb +11 -9
- data/lib/puppet-strings/monkey_patches/display_object_command.rb +2 -0
- data/lib/puppet-strings/tasks/generate.rb +2 -0
- data/lib/puppet-strings/tasks/gh_pages.rb +3 -0
- data/lib/puppet-strings/tasks/validate.rb +42 -0
- data/lib/puppet-strings/tasks.rb +3 -0
- data/lib/puppet-strings/version.rb +3 -1
- data/lib/puppet-strings/yard/code_objects/base.rb +2 -0
- data/lib/puppet-strings/yard/code_objects/class.rb +4 -2
- data/lib/puppet-strings/yard/code_objects/data_type.rb +4 -2
- data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +2 -0
- data/lib/puppet-strings/yard/code_objects/defined_type.rb +4 -2
- data/lib/puppet-strings/yard/code_objects/function.rb +6 -3
- data/lib/puppet-strings/yard/code_objects/group.rb +3 -0
- data/lib/puppet-strings/yard/code_objects/plan.rb +4 -2
- data/lib/puppet-strings/yard/code_objects/provider.rb +6 -0
- data/lib/puppet-strings/yard/code_objects/task.rb +2 -0
- data/lib/puppet-strings/yard/code_objects/type.rb +6 -1
- data/lib/puppet-strings/yard/code_objects.rb +2 -0
- data/lib/puppet-strings/yard/handlers/helpers.rb +2 -0
- data/lib/puppet-strings/yard/handlers/json/base.rb +2 -0
- data/lib/puppet-strings/yard/handlers/json/task_handler.rb +2 -0
- data/lib/puppet-strings/yard/handlers/puppet/base.rb +3 -0
- data/lib/puppet-strings/yard/handlers/puppet/class_handler.rb +2 -0
- data/lib/puppet-strings/yard/handlers/puppet/data_type_alias_handler.rb +2 -0
- data/lib/puppet-strings/yard/handlers/puppet/defined_type_handler.rb +2 -0
- data/lib/puppet-strings/yard/handlers/puppet/function_handler.rb +3 -1
- data/lib/puppet-strings/yard/handlers/puppet/plan_handler.rb +2 -0
- data/lib/puppet-strings/yard/handlers/ruby/base.rb +5 -0
- data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +33 -17
- data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +9 -7
- data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +13 -0
- data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +4 -1
- data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +14 -6
- data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +15 -5
- data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +12 -1
- data/lib/puppet-strings/yard/handlers.rb +2 -0
- data/lib/puppet-strings/yard/parsers/json/parser.rb +2 -0
- data/lib/puppet-strings/yard/parsers/json/task_statement.rb +2 -0
- data/lib/puppet-strings/yard/parsers/puppet/parser.rb +18 -14
- data/lib/puppet-strings/yard/parsers/puppet/statement.rb +4 -0
- data/lib/puppet-strings/yard/parsers.rb +2 -0
- data/lib/puppet-strings/yard/tags/enum_tag.rb +2 -0
- data/lib/puppet-strings/yard/tags/factory.rb +2 -0
- data/lib/puppet-strings/yard/tags/overload_tag.rb +4 -1
- data/lib/puppet-strings/yard/tags/parameter_directive.rb +5 -4
- data/lib/puppet-strings/yard/tags/property_directive.rb +5 -4
- data/lib/puppet-strings/yard/tags/summary_tag.rb +2 -0
- data/lib/puppet-strings/yard/tags.rb +2 -0
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +1 -1
- data/lib/puppet-strings/yard/util.rb +4 -1
- data/lib/puppet-strings/yard.rb +3 -0
- data/lib/puppet-strings.rb +2 -0
- metadata +9 -8
@@ -1,4 +1,4 @@
|
|
1
|
-
###
|
1
|
+
### <a name="<%= link %>"></a>`<%= name %>`
|
2
2
|
|
3
3
|
<% if text -%>
|
4
4
|
<%= text %>
|
@@ -47,10 +47,14 @@
|
|
47
47
|
<% if params -%>
|
48
48
|
#### Parameters
|
49
49
|
|
50
|
-
The following parameters are available in the `<%= name %>` <%= @type
|
50
|
+
The following parameters are available in the `<%= name %>` <%= @type %>:
|
51
51
|
|
52
52
|
<% params.each do |param| -%>
|
53
|
-
|
53
|
+
* [`<%= param[:name] %>`](#<%= param[:name] %>)
|
54
|
+
<% end -%>
|
55
|
+
|
56
|
+
<% params.each do |param| -%>
|
57
|
+
##### <a name="<%= param[:name] %>"></a>`<%= param[:name] %>`
|
54
58
|
|
55
59
|
<% if param[:types] -%>
|
56
60
|
Data type: `<%= param[:types].join(', ') -%>`
|
@@ -1,4 +1,4 @@
|
|
1
|
-
###
|
1
|
+
### <a name="<%= link %>"></a>`<%= name %>`
|
2
2
|
|
3
3
|
<% if text -%>
|
4
4
|
<%= text %>
|
@@ -45,16 +45,24 @@
|
|
45
45
|
<% end -%>
|
46
46
|
<% end -%>
|
47
47
|
<% if alias_of -%>
|
48
|
-
Alias of
|
48
|
+
Alias of
|
49
|
+
|
50
|
+
```puppet
|
51
|
+
<%= alias_of %>
|
52
|
+
```
|
49
53
|
|
50
54
|
<% end -%>
|
51
55
|
<% if params -%>
|
52
56
|
#### Parameters
|
53
57
|
|
54
|
-
The following parameters are available in the `<%= name %>` <%= @type
|
58
|
+
The following parameters are available in the `<%= name %>` <%= @type %>:
|
59
|
+
|
60
|
+
<% params.each do |param| -%>
|
61
|
+
* [`<%= param[:name] %>`](#<%= param[:name] %>)
|
62
|
+
<% end -%>
|
55
63
|
|
56
64
|
<% params.each do |param| -%>
|
57
|
-
#####
|
65
|
+
##### <a name="<%= param[:name] %>"></a>`<%= param[:name] %>`
|
58
66
|
|
59
67
|
<% if param[:types] -%>
|
60
68
|
Data type: `<%= param[:types].join(', ') -%>`
|
@@ -1,4 +1,4 @@
|
|
1
|
-
###
|
1
|
+
### <a name="<%= link %>"></a>`<%= name %>`
|
2
2
|
|
3
3
|
<% if text -%>
|
4
4
|
<%= text %>
|
@@ -98,7 +98,11 @@ Default value: `<%= prop[:default] %>`
|
|
98
98
|
The following parameters are available in the `<%= name %>` <%= @type %>.
|
99
99
|
|
100
100
|
<% parameters.each do |param| -%>
|
101
|
-
|
101
|
+
* [`<%= param[:name] %>`](#<%= param[:name] %>)
|
102
|
+
<% end -%>
|
103
|
+
|
104
|
+
<% parameters.each do |param| -%>
|
105
|
+
##### <a name="<%= param[:name] %>"></a>`<%= param[:name] %>`
|
102
106
|
|
103
107
|
<% if param[:values] -%>
|
104
108
|
Valid values: `<%= param[:values].map { |value| value_string(value) }.join('`, `') %>`
|
@@ -116,7 +120,9 @@ Aliases: `<%= param[:aliases].to_s.delete('{').delete('}') %>`
|
|
116
120
|
Data type: `<%= param[:data_type] %>`<%= "\n_\*this data type contains a regex that may not be accurately reflected in generated documentation_" if regex_in_data_type?(param[:data_type]) %>
|
117
121
|
|
118
122
|
<% end -%>
|
123
|
+
<% if param[:description] -%>
|
119
124
|
<%= word_wrap(param[:description]) %>
|
125
|
+
<% end -%>
|
120
126
|
|
121
127
|
<% if options_for_param(param[:name]) -%>
|
122
128
|
Options:
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/json'
|
2
4
|
|
3
5
|
# module for parsing Yard Registries and generating markdown
|
@@ -15,15 +17,15 @@ module PuppetStrings::Markdown
|
|
15
17
|
# @return [String] markdown doc
|
16
18
|
def self.generate
|
17
19
|
final = "# Reference\n\n"
|
18
|
-
final
|
19
|
-
final
|
20
|
-
final
|
21
|
-
final
|
22
|
-
final
|
23
|
-
final
|
24
|
-
final
|
25
|
-
final
|
26
|
-
final
|
20
|
+
final += "<!-- DO NOT EDIT: This document was generated by Puppet Strings -->\n\n"
|
21
|
+
final += PuppetStrings::Markdown::TableOfContents.render
|
22
|
+
final += PuppetStrings::Markdown::PuppetClasses.render
|
23
|
+
final += PuppetStrings::Markdown::DefinedTypes.render
|
24
|
+
final += PuppetStrings::Markdown::ResourceTypes.render
|
25
|
+
final += PuppetStrings::Markdown::Functions.render
|
26
|
+
final += PuppetStrings::Markdown::DataTypes.render
|
27
|
+
final += PuppetStrings::Markdown::PuppetTasks.render
|
28
|
+
final += PuppetStrings::Markdown::PuppetPlans.render
|
27
29
|
|
28
30
|
final
|
29
31
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/tasks'
|
2
4
|
|
3
5
|
namespace :strings do
|
@@ -5,6 +7,7 @@ namespace :strings do
|
|
5
7
|
task :checkout do
|
6
8
|
if Dir.exist?('doc')
|
7
9
|
fail "The 'doc' directory (#{File.expand_path('doc')}) is not a Git repository! Remove it and run the Rake task again." unless Dir.exist?('doc/.git')
|
10
|
+
|
8
11
|
Dir.chdir('doc') do
|
9
12
|
system 'git checkout gh-pages'
|
10
13
|
system 'git pull --rebase origin gh-pages'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'puppet-strings'
|
4
|
+
require 'tempfile'
|
5
|
+
|
6
|
+
namespace :strings do
|
7
|
+
namespace :validate do
|
8
|
+
desc 'Validate the reference is up to date'
|
9
|
+
task :reference, [:patterns, :debug, :backtrace] do |t, args|
|
10
|
+
filename = 'REFERENCE.md'
|
11
|
+
|
12
|
+
unless File.exist?(filename)
|
13
|
+
STDERR.puts "#{filename} does not exist"
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
17
|
+
patterns = args[:patterns]
|
18
|
+
patterns = patterns.split if patterns
|
19
|
+
patterns ||= PuppetStrings::DEFAULT_SEARCH_PATTERNS
|
20
|
+
|
21
|
+
generated = Tempfile.create do |file|
|
22
|
+
options = {
|
23
|
+
debug: args[:debug] == 'true',
|
24
|
+
backtrace: args[:backtrace] == 'true',
|
25
|
+
json: false,
|
26
|
+
markdown: true,
|
27
|
+
path: file,
|
28
|
+
}
|
29
|
+
PuppetStrings.generate(patterns, options)
|
30
|
+
|
31
|
+
file.read
|
32
|
+
end
|
33
|
+
|
34
|
+
existing = File.read(filename)
|
35
|
+
|
36
|
+
if generated != existing
|
37
|
+
STDERR.puts "#{filename} is outdated"
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/puppet-strings/tasks.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake'
|
2
4
|
require 'rake/tasklib'
|
3
5
|
|
@@ -6,5 +8,6 @@ module PuppetStrings
|
|
6
8
|
module Tasks
|
7
9
|
require 'puppet-strings/tasks/generate.rb'
|
8
10
|
require 'puppet-strings/tasks/gh_pages.rb'
|
11
|
+
require 'puppet-strings/tasks/validate.rb'
|
9
12
|
end
|
10
13
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/code_objects/group'
|
2
4
|
|
3
5
|
# Implements the group for Puppet classes.
|
@@ -52,8 +54,8 @@ class PuppetStrings::Yard::CodeObjects::Class < PuppetStrings::Yard::CodeObjects
|
|
52
54
|
hash[:inherits] = statement.parent_class if statement.parent_class
|
53
55
|
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
|
54
56
|
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
|
55
|
-
hash[:defaults] = defaults unless defaults.empty?
|
56
|
-
hash[:source] = source unless source
|
57
|
+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
|
58
|
+
hash[:source] = source unless source.nil? || source.empty?
|
57
59
|
hash
|
58
60
|
end
|
59
61
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/code_objects/group'
|
2
4
|
require 'puppet-strings/yard/util'
|
3
5
|
|
@@ -86,8 +88,8 @@ class PuppetStrings::Yard::CodeObjects::DataType < PuppetStrings::Yard::CodeObje
|
|
86
88
|
hash[:file] = file
|
87
89
|
hash[:line] = line
|
88
90
|
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example])
|
89
|
-
hash[:defaults] = defaults unless defaults.empty?
|
90
|
-
hash[:source] = source unless source
|
91
|
+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
|
92
|
+
hash[:source] = source unless source.nil? || source.empty?
|
91
93
|
hash[:functions] = functions.map do |func|
|
92
94
|
{
|
93
95
|
name: func.name,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/code_objects/group'
|
2
4
|
|
3
5
|
# Implements the group for Puppet defined types.
|
@@ -51,8 +53,8 @@ class PuppetStrings::Yard::CodeObjects::DefinedType < PuppetStrings::Yard::CodeO
|
|
51
53
|
hash[:line] = line
|
52
54
|
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
|
53
55
|
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
|
54
|
-
hash[:defaults] = defaults unless defaults.empty?
|
55
|
-
hash[:source] = source unless source
|
56
|
+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
|
57
|
+
hash[:source] = source unless source.nil? || source.empty?
|
56
58
|
hash
|
57
59
|
end
|
58
60
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/code_objects/group'
|
2
4
|
|
3
5
|
# Implements the group for Puppet functions.
|
@@ -61,11 +63,12 @@ class PuppetStrings::Yard::CodeObjects::Function < PuppetStrings::Yard::CodeObje
|
|
61
63
|
# @return [String] Returns the Puppet signature of the function.
|
62
64
|
def signature
|
63
65
|
return '' if self.has_tag? :overload
|
66
|
+
|
64
67
|
tags = self.tags(:param)
|
65
68
|
args = @parameters.map do |parameter|
|
66
69
|
name, default = parameter
|
67
70
|
tag = tags.find { |t| t.name == name } if tags
|
68
|
-
type = tag
|
71
|
+
type = tag&.types ? "#{tag.type} " : 'Any '
|
69
72
|
prefix = "#{name[0]}" if name.start_with?('*', '&')
|
70
73
|
name = name[1..-1] if prefix
|
71
74
|
default = " = #{default}" if default
|
@@ -96,8 +99,8 @@ class PuppetStrings::Yard::CodeObjects::Function < PuppetStrings::Yard::CodeObje
|
|
96
99
|
|
97
100
|
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
|
98
101
|
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
|
99
|
-
hash[:defaults] = defaults unless defaults.empty?
|
100
|
-
hash[:source] = source unless source
|
102
|
+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
|
103
|
+
hash[:source] = source unless source.nil? || source.empty?
|
101
104
|
hash
|
102
105
|
end
|
103
106
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/code_objects/base'
|
2
4
|
|
3
5
|
# Implements the base class for "groups".
|
@@ -10,6 +12,7 @@ class PuppetStrings::Yard::CodeObjects::Group < PuppetStrings::Yard::CodeObjects
|
|
10
12
|
def self.instance(key)
|
11
13
|
instance = P(:root, key)
|
12
14
|
return instance unless instance.is_a?(YARD::CodeObjects::Proxy)
|
15
|
+
|
13
16
|
instance = self.new(:root, key)
|
14
17
|
instance.visibility = :hidden
|
15
18
|
P(:root).children << instance
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/code_objects/group'
|
2
4
|
|
3
5
|
class PuppetStrings::Yard::CodeObjects::Plans < PuppetStrings::Yard::CodeObjects::Group
|
@@ -49,8 +51,8 @@ class PuppetStrings::Yard::CodeObjects::Plan < PuppetStrings::Yard::CodeObjects:
|
|
49
51
|
hash[:line] = line
|
50
52
|
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
|
51
53
|
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
|
52
|
-
hash[:defaults] = defaults unless defaults.empty?
|
53
|
-
hash[:source] = source unless source
|
54
|
+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
|
55
|
+
hash[:source] = source unless source.nil? || source.empty?
|
54
56
|
hash
|
55
57
|
end
|
56
58
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/code_objects/group'
|
2
4
|
|
3
5
|
# Implements the group for Puppet providers.
|
@@ -42,6 +44,7 @@ class PuppetStrings::Yard::CodeObjects::Provider < PuppetStrings::Yard::CodeObje
|
|
42
44
|
# @return [void]
|
43
45
|
def add_confine(key, value)
|
44
46
|
return unless key && value
|
47
|
+
|
45
48
|
@confines ||= {}
|
46
49
|
@confines[key] = value
|
47
50
|
end
|
@@ -51,6 +54,7 @@ class PuppetStrings::Yard::CodeObjects::Provider < PuppetStrings::Yard::CodeObje
|
|
51
54
|
# @return [void]
|
52
55
|
def add_feature(feature)
|
53
56
|
return unless feature
|
57
|
+
|
54
58
|
@features ||= []
|
55
59
|
@features << feature
|
56
60
|
end
|
@@ -60,6 +64,7 @@ class PuppetStrings::Yard::CodeObjects::Provider < PuppetStrings::Yard::CodeObje
|
|
60
64
|
# @return [void]
|
61
65
|
def add_default(constraints)
|
62
66
|
return unless constraints
|
67
|
+
|
63
68
|
@defaults ||= []
|
64
69
|
@defaults << constraints
|
65
70
|
end
|
@@ -70,6 +75,7 @@ class PuppetStrings::Yard::CodeObjects::Provider < PuppetStrings::Yard::CodeObje
|
|
70
75
|
# @return [void]
|
71
76
|
def add_command(key, value)
|
72
77
|
return unless key && value
|
78
|
+
|
73
79
|
@commands ||= {}
|
74
80
|
@commands[key] = value
|
75
81
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/code_objects/group'
|
2
4
|
require 'puppet-strings/yard/util'
|
3
5
|
|
@@ -146,11 +148,12 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects:
|
|
146
148
|
end
|
147
149
|
|
148
150
|
def parameters
|
151
|
+
@parameters ||= [] # guard against not filled parameters
|
149
152
|
# just return params if there are no providers
|
150
153
|
return @parameters if providers.empty?
|
151
154
|
|
152
155
|
# return existing params if we have already added provider
|
153
|
-
return @parameters if @parameters
|
156
|
+
return @parameters if @parameters&.any? { |p| p.name == 'provider' }
|
154
157
|
|
155
158
|
provider_param = Parameter.new(
|
156
159
|
'provider',
|
@@ -158,6 +161,7 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects:
|
|
158
161
|
"to specify this --- Puppet will usually discover the appropriate provider for your platform."
|
159
162
|
)
|
160
163
|
|
164
|
+
@parameters ||= []
|
161
165
|
@parameters << provider_param
|
162
166
|
end
|
163
167
|
|
@@ -167,6 +171,7 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects:
|
|
167
171
|
def providers
|
168
172
|
providers = YARD::Registry.all("puppet_providers_#{name}".intern)
|
169
173
|
return providers if providers.empty?
|
174
|
+
|
170
175
|
providers.first.children
|
171
176
|
end
|
172
177
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Implements the base handler for Puppet language handlers.
|
2
4
|
class PuppetStrings::Yard::Handlers::Puppet::Base < YARD::Handlers::Base
|
3
5
|
# Determine sif the handler handles the given statement.
|
@@ -17,6 +19,7 @@ class PuppetStrings::Yard::Handlers::Puppet::Base < YARD::Handlers::Base
|
|
17
19
|
tags = object.tags(:param)
|
18
20
|
tags.each do |tag|
|
19
21
|
next if statement.parameters.find { |p| tag.name == p.name }
|
22
|
+
|
20
23
|
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}." unless tag.name == 'name' || tag.name == 'title'
|
21
24
|
end
|
22
25
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-strings/yard/handlers/helpers'
|
2
4
|
require 'puppet-strings/yard/handlers/puppet/base'
|
3
5
|
require 'puppet-strings/yard/parsers'
|
@@ -37,7 +39,7 @@ class PuppetStrings::Yard::Handlers::Puppet::FunctionHandler < PuppetStrings::Ya
|
|
37
39
|
def add_return_tag(object, type=nil)
|
38
40
|
tag = object.tag(:return)
|
39
41
|
if tag
|
40
|
-
if (type && tag.types.first) && (type != tag.types.first)
|
42
|
+
if (type && tag.types && tag.types.first) && (type != tag.types.first)
|
41
43
|
log.warn "Documented return type does not match return type in function definition near #{statement.file}:#{statement.line}."
|
42
44
|
end
|
43
45
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ripper'
|
2
4
|
|
3
5
|
# Implements the base handler for Ruby language handlers.
|
@@ -12,6 +14,7 @@ class PuppetStrings::Yard::Handlers::Ruby::Base < YARD::Handlers::Ruby::Base
|
|
12
14
|
# @return [String] Returns a string representation of the node or nil if a string representation was not possible.
|
13
15
|
def node_as_string(node)
|
14
16
|
return nil unless node
|
17
|
+
|
15
18
|
case node.type
|
16
19
|
when :symbol, :symbol_literal
|
17
20
|
node.source[1..-1]
|
@@ -42,8 +45,10 @@ class PuppetStrings::Yard::Handlers::Ruby::Base < YARD::Handlers::Ruby::Base
|
|
42
45
|
def get_name(statementobject, statementtype)
|
43
46
|
parameters = statementobject.parameters(false)
|
44
47
|
raise YARD::Parser::UndocumentableError, "Expected at least one parameter to #{statementtype} at #{statementobject.file}:#{statementobject.line}." if parameters.empty?
|
48
|
+
|
45
49
|
name = node_as_string(parameters.first)
|
46
50
|
raise YARD::Parser::UndocumentableError, "Expected a symbol or string literal for first parameter but found '#{parameters.first.type}' at #{statement.file}:#{statement.line}." unless name
|
51
|
+
|
47
52
|
name
|
48
53
|
end
|
49
54
|
end
|