puppet-strings 2.3.0 → 2.7.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 +102 -4
- data/COMMITTERS.md +17 -17
- data/CONTRIBUTING.md +37 -7
- data/README.md +17 -12
- data/lib/puppet-strings.rb +5 -3
- data/lib/puppet-strings/describe.rb +2 -0
- data/lib/puppet-strings/json.rb +2 -0
- data/lib/puppet-strings/markdown.rb +12 -10
- data/lib/puppet-strings/markdown/base.rb +30 -3
- data/lib/puppet-strings/markdown/data_type.rb +18 -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 +21 -2
- 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 +18 -6
- data/lib/puppet-strings/markdown/templates/data_type.erb +30 -7
- data/lib/puppet-strings/markdown/templates/data_type_function.erb +67 -0
- data/lib/puppet-strings/markdown/templates/function.erb +10 -1
- data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
- data/lib/puppet-strings/markdown/templates/resource_type.erb +35 -13
- data/lib/puppet-strings/markdown/templates/table_of_contents.erb +6 -6
- data/lib/puppet-strings/monkey_patches/display_object_command.rb +2 -0
- data/lib/puppet-strings/tasks.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/version.rb +3 -1
- data/lib/puppet-strings/yard.rb +9 -0
- data/lib/puppet-strings/yard/code_objects.rb +2 -0
- 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 +30 -8
- 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 +8 -5
- 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 +3 -1
- data/lib/puppet-strings/yard/code_objects/type.rb +49 -5
- data/lib/puppet-strings/yard/handlers.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 +225 -52
- 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 +20 -6
- data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +6 -3
- data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +18 -1
- data/lib/puppet-strings/yard/parsers.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/tags.rb +4 -0
- data/lib/puppet-strings/yard/tags/enum_tag.rb +14 -0
- data/lib/puppet-strings/yard/tags/factory.rb +18 -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/templates/default/puppet_data_type/html/method_details_list.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +9 -1
- data/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +1 -1
- 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 +6 -0
- data/lib/puppet-strings/yard/util.rb +7 -4
- 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
- metadata +14 -51
- data/Gemfile +0 -47
- data/HISTORY.md +0 -218
- data/JSON.md +0 -832
- data/Rakefile +0 -168
- data/codecov.yml +0 -3
- data/misc/ANNOUNCEMENT_TEMPLATE.md +0 -40
- data/spec/acceptance/emit_json_options_spec.rb +0 -69
- data/spec/acceptance/generate_markdown_spec.rb +0 -47
- data/spec/acceptance/running_strings_generate_spec.rb +0 -78
- 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 -10
- data/spec/fixtures/acceptance/modules/test/types/elephant.pp +0 -2
- data/spec/fixtures/unit/markdown/output.md +0 -508
- data/spec/fixtures/unit/markdown/output_with_data_types.md +0 -553
- data/spec/fixtures/unit/markdown/output_with_plan.md +0 -542
- data/spec/spec_helper.rb +0 -49
- data/spec/spec_helper_acceptance.rb +0 -58
- data/spec/spec_helper_acceptance_local.rb +0 -10
- data/spec/unit/puppet-strings/describe_spec.rb +0 -141
- data/spec/unit/puppet-strings/json_spec.rb +0 -302
- data/spec/unit/puppet-strings/markdown/base_spec.rb +0 -146
- data/spec/unit/puppet-strings/markdown_spec.rb +0 -357
- 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 -116
- data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +0 -217
- data/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +0 -65
- 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/data_type_handler_spec.rb +0 -232
- data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +0 -746
- data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +0 -158
- data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +0 -235
- data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +0 -311
- data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +0 -72
- 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 -251
- data/spec/unit/puppet-strings/yard/util_spec.rb +0 -48
@@ -0,0 +1,67 @@
|
|
1
|
+
### <a name="<%= link %>"></a>`<%= name %>`
|
2
|
+
|
3
|
+
#### `<%= signature %>`
|
4
|
+
|
5
|
+
<% if text -%>
|
6
|
+
<%= text %>
|
7
|
+
|
8
|
+
<% elsif summary -%>
|
9
|
+
<%= summary %>
|
10
|
+
|
11
|
+
<% else -%>
|
12
|
+
<%= "The #{name} function." %>
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
<% if note -%>
|
16
|
+
* **Note** <%= note %>
|
17
|
+
|
18
|
+
<% end -%>
|
19
|
+
<% if return_type -%>
|
20
|
+
Returns: `<%= return_type %>`<% if return_val %> <%= return_val %><% end %>
|
21
|
+
|
22
|
+
<% end -%>
|
23
|
+
<% if raises -%>
|
24
|
+
Raises:
|
25
|
+
<% raises.each do |r| -%>
|
26
|
+
* <%= error_type(r[:text]) %> <%= error_text(r[:text]) %>
|
27
|
+
<% end -%>
|
28
|
+
|
29
|
+
<% end -%>
|
30
|
+
<% if examples -%>
|
31
|
+
##### Examples
|
32
|
+
|
33
|
+
<% examples.each do |eg| -%>
|
34
|
+
###### <%= eg[:name] %>
|
35
|
+
|
36
|
+
```puppet
|
37
|
+
<%= eg[:text] %>
|
38
|
+
```
|
39
|
+
|
40
|
+
<% end -%>
|
41
|
+
<% end -%>
|
42
|
+
<% if params -%>
|
43
|
+
<% params.each do |param| -%>
|
44
|
+
##### `<%= param[:name] %>`
|
45
|
+
|
46
|
+
Data type: `<%= param[:types][0] %>`
|
47
|
+
|
48
|
+
<%= param[:text] %>
|
49
|
+
|
50
|
+
<% if options_for_param(param[:name]) -%>
|
51
|
+
Options:
|
52
|
+
|
53
|
+
<% options_for_param(param[:name]).each do |o| -%>
|
54
|
+
* **<%= o[:opt_name] %>** `<%= o[:opt_types][0] %>`: <%= o[:opt_text] %>
|
55
|
+
<% end -%>
|
56
|
+
|
57
|
+
<% end -%>
|
58
|
+
<% if enums_for_param(param[:name]) -%>
|
59
|
+
Options:
|
60
|
+
|
61
|
+
<% enums_for_param(param[:name]).each do |e| -%>
|
62
|
+
* **<%= e[:opt_name] %>**: <%= e[:opt_text] %>
|
63
|
+
<% end -%>
|
64
|
+
|
65
|
+
<% end -%>
|
66
|
+
<% end -%>
|
67
|
+
<% end -%>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
### <%= name
|
1
|
+
### <a name="<%= link %>"></a>`<%= name %>`
|
2
2
|
|
3
3
|
Type: <%= type %>
|
4
4
|
|
@@ -55,6 +55,7 @@ Returns: `<%= sig.return_type %>`<% if sig.return_val %> <%= sig.return_val %><%
|
|
55
55
|
<% end -%>
|
56
56
|
<% if raises -%>
|
57
57
|
Raises:
|
58
|
+
|
58
59
|
<% raises.each do |r| -%>
|
59
60
|
* <%= error_type(r[:text]) %> <%= error_text(r[:text]) %>
|
60
61
|
<% end -%>
|
@@ -87,6 +88,14 @@ Options:
|
|
87
88
|
* **<%= o[:opt_name] %>** `<%= o[:opt_types][0] %>`: <%= o[:opt_text] %>
|
88
89
|
<% end -%>
|
89
90
|
|
91
|
+
<% end -%>
|
92
|
+
<% if sig.enums_for_param(param[:name]) -%>
|
93
|
+
Options:
|
94
|
+
|
95
|
+
<% sig.enums_for_param(param[:name]).each do |e| -%>
|
96
|
+
* **<%= e[:opt_name] %>**: <%= e[:opt_text] %>
|
97
|
+
<% end -%>
|
98
|
+
|
90
99
|
<% end -%>
|
91
100
|
<% end -%>
|
92
101
|
<% end -%>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
### <%= name
|
1
|
+
### <a name="<%= link %>"></a>`<%= name %>`
|
2
2
|
|
3
3
|
<% if text -%>
|
4
4
|
<%= text %>
|
@@ -24,10 +24,10 @@
|
|
24
24
|
* **See also**
|
25
25
|
<% see.each do |sa| -%>
|
26
26
|
<% if sa[:name] -%>
|
27
|
-
<%= sa[:name] %>
|
27
|
+
<%= " * #{sa[:name]}" %>
|
28
28
|
<% end -%>
|
29
29
|
<% if sa[:text] -%>
|
30
|
-
<%= sa[:text] %>
|
30
|
+
<%= " * #{sa[:text]}" %>
|
31
31
|
<% end -%>
|
32
32
|
<% end -%>
|
33
33
|
|
@@ -44,16 +44,16 @@
|
|
44
44
|
|
45
45
|
<% end -%>
|
46
46
|
<% end -%>
|
47
|
-
<% if
|
47
|
+
<% if properties_and_checks -%>
|
48
48
|
#### Properties
|
49
49
|
|
50
50
|
The following properties are available in the `<%= name %>` <%= @type %>.
|
51
51
|
|
52
|
-
<%
|
52
|
+
<% properties_and_checks.each do |prop| -%>
|
53
53
|
##### `<%= prop[:name] %>`
|
54
54
|
|
55
55
|
<% if prop[:values] -%>
|
56
|
-
Valid values:
|
56
|
+
Valid values: `<%= prop[:values].map { |value| value_string(value) }.join('`, `') %>`
|
57
57
|
|
58
58
|
<% end -%>
|
59
59
|
<% if prop[:isnamevar] -%>
|
@@ -61,7 +61,7 @@ namevar
|
|
61
61
|
|
62
62
|
<% end -%>
|
63
63
|
<% if prop[:aliases] -%>
|
64
|
-
Aliases:
|
64
|
+
Aliases: `<%= prop[:aliases].to_s.delete('{').delete('}') %>`
|
65
65
|
|
66
66
|
<% end -%>
|
67
67
|
<% if prop[:data_type] -%>
|
@@ -77,9 +77,17 @@ Options:
|
|
77
77
|
* **<%= o[:opt_name] %>** `<%= o[:opt_types][0] %>`: <%= o[:opt_text] %>
|
78
78
|
<% end -%>
|
79
79
|
|
80
|
+
<% end -%>
|
81
|
+
<% if enums_for_param(prop[:name]) -%>
|
82
|
+
Options:
|
83
|
+
|
84
|
+
<% enums_for_param(prop[:name]).each do |e| -%>
|
85
|
+
* **<%= e[:opt_name] %>**: <%= e[:opt_text] %>
|
86
|
+
<% end -%>
|
87
|
+
|
80
88
|
<% end -%>
|
81
89
|
<% if prop[:default] -%>
|
82
|
-
Default value:
|
90
|
+
Default value: `<%= prop[:default] %>`
|
83
91
|
|
84
92
|
<% end -%>
|
85
93
|
<% end -%>
|
@@ -90,10 +98,14 @@ Default value: <%= prop[:default] %>
|
|
90
98
|
The following parameters are available in the `<%= name %>` <%= @type %>.
|
91
99
|
|
92
100
|
<% parameters.each do |param| -%>
|
93
|
-
|
101
|
+
* [`<%= param[:name] %>`](#<%= param[:name] %>)
|
102
|
+
<% end -%>
|
103
|
+
|
104
|
+
<% parameters.each do |param| -%>
|
105
|
+
##### <a name="<%= param[:name] %>"></a>`<%= param[:name] %>`
|
94
106
|
|
95
107
|
<% if param[:values] -%>
|
96
|
-
Valid values:
|
108
|
+
Valid values: `<%= param[:values].map { |value| value_string(value) }.join('`, `') %>`
|
97
109
|
|
98
110
|
<% end -%>
|
99
111
|
<% if param[:isnamevar] -%>
|
@@ -101,14 +113,16 @@ namevar
|
|
101
113
|
|
102
114
|
<% end -%>
|
103
115
|
<% if param[:aliases] -%>
|
104
|
-
Aliases:
|
116
|
+
Aliases: `<%= param[:aliases].to_s.delete('{').delete('}') %>`
|
105
117
|
|
106
118
|
<% end -%>
|
107
119
|
<% if param[:data_type] -%>
|
108
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]) %>
|
109
121
|
|
110
122
|
<% end -%>
|
111
|
-
|
123
|
+
<% if param[:description] -%>
|
124
|
+
<%= word_wrap(param[:description]) %>
|
125
|
+
<% end -%>
|
112
126
|
|
113
127
|
<% if options_for_param(param[:name]) -%>
|
114
128
|
Options:
|
@@ -117,9 +131,17 @@ Options:
|
|
117
131
|
* **<%= o[:opt_name] %>** `<%= o[:opt_types][0] %>`: <%= o[:opt_text] %>
|
118
132
|
<% end -%>
|
119
133
|
|
134
|
+
<% end -%>
|
135
|
+
<% if enums_for_param(param[:name]) -%>
|
136
|
+
Options:
|
137
|
+
|
138
|
+
<% enums_for_param(param[:name]).each do |e| -%>
|
139
|
+
* **<%= e[:opt_name] %>**: <%= e[:opt_text] %>
|
140
|
+
<% end -%>
|
141
|
+
|
120
142
|
<% end -%>
|
121
143
|
<% if param[:default] -%>
|
122
|
-
Default value:
|
144
|
+
Default value: `<%= value_string(param[:default]) %>`
|
123
145
|
|
124
146
|
<% end -%>
|
125
147
|
<% if param[:required_features] -%>
|
@@ -1,25 +1,25 @@
|
|
1
1
|
<% if group.length > 0 -%>
|
2
|
-
|
2
|
+
### <%= group_name %>
|
3
3
|
|
4
4
|
<% if priv -%>
|
5
|
-
|
5
|
+
#### Public <%= group_name %>
|
6
6
|
|
7
7
|
<% group.each do |item| -%>
|
8
8
|
<% unless item[:private] -%>
|
9
|
-
* [`<%= item[:name] %>`](#<%= item[:link] %>): <%= item[:desc] %>
|
9
|
+
* [`<%= item[:name] %>`](#<%= item[:link] %>)<% unless item[:desc].nil? || item[:desc].empty? %>: <%= item[:desc] %><% end %>
|
10
10
|
<% end -%>
|
11
11
|
<% end -%>
|
12
12
|
|
13
|
-
|
13
|
+
#### Private <%= group_name %>
|
14
14
|
|
15
15
|
<% group.each do |item| -%>
|
16
16
|
<% if item[:private] -%>
|
17
|
-
* `<%= item[:name]
|
17
|
+
* `<%= item[:name] %>`<% unless item[:desc].nil? || item[:desc].empty? %>: <%= item[:desc] %><% end %>
|
18
18
|
<% end -%>
|
19
19
|
<% end -%>
|
20
20
|
<% else -%>
|
21
21
|
<% group.each do |item| -%>
|
22
|
-
* [`<%= item[:name] %>`](#<%= item[:link] %>): <%= item[:desc] %>
|
22
|
+
* [`<%= item[:name] %>`](#<%= item[:link] %>)<% unless item[:desc].nil? || item[:desc].empty? %>: <%= item[:desc] %><% end %>
|
23
23
|
<% end -%>
|
24
24
|
<% end -%>
|
25
25
|
|
data/lib/puppet-strings/tasks.rb
CHANGED
@@ -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'
|
data/lib/puppet-strings/yard.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yard'
|
2
4
|
|
3
5
|
# Module for YARD related functionality.
|
@@ -11,6 +13,9 @@ module PuppetStrings::Yard
|
|
11
13
|
# Sets up YARD for use with puppet-strings.
|
12
14
|
# @return [void]
|
13
15
|
def self.setup!
|
16
|
+
# Register our factory
|
17
|
+
YARD::Tags::Library.default_factory = PuppetStrings::Yard::Tags::Factory
|
18
|
+
|
14
19
|
# Register the template path
|
15
20
|
YARD::Templates::Engine.register_template_path(File.join(File.dirname(__FILE__), 'yard', 'templates'))
|
16
21
|
|
@@ -30,6 +35,9 @@ module PuppetStrings::Yard
|
|
30
35
|
# Register the summary tag
|
31
36
|
PuppetStrings::Yard::Tags::SummaryTag.register!
|
32
37
|
|
38
|
+
# Register the enum tag
|
39
|
+
PuppetStrings::Yard::Tags::EnumTag.register!
|
40
|
+
|
33
41
|
# Ignore documentation on Puppet DSL calls
|
34
42
|
# This prevents the YARD DSL parser from emitting warnings for Puppet's Ruby DSL
|
35
43
|
YARD::Handlers::Ruby::DSLHandlerMethods::IGNORE_METHODS['create_function'] = true
|
@@ -96,6 +104,7 @@ class YARD::CLI::Stats
|
|
96
104
|
|
97
105
|
def stats_for_puppet_plans
|
98
106
|
return unless PuppetStrings.puppet_5?
|
107
|
+
|
99
108
|
output 'Puppet Plans', *type_statistics_all(:puppet_plan)
|
100
109
|
end
|
101
110
|
|
@@ -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
|
|
@@ -24,7 +26,6 @@ class PuppetStrings::Yard::CodeObjects::DataType < PuppetStrings::Yard::CodeObje
|
|
24
26
|
# @return [void]
|
25
27
|
def initialize(name)
|
26
28
|
super(PuppetStrings::Yard::CodeObjects::DataTypes.instance, name)
|
27
|
-
@parameters = []
|
28
29
|
@defaults = {}
|
29
30
|
end
|
30
31
|
|
@@ -41,10 +42,6 @@ class PuppetStrings::Yard::CodeObjects::DataType < PuppetStrings::Yard::CodeObje
|
|
41
42
|
nil
|
42
43
|
end
|
43
44
|
|
44
|
-
def parameter_exist?(name)
|
45
|
-
!docstring.tags(:param).find { |item| item.name == name }.nil?
|
46
|
-
end
|
47
|
-
|
48
45
|
def add_parameter(name, type, default)
|
49
46
|
tag = docstring.tags(:param).find { |item| item.name == name }
|
50
47
|
if tag.nil?
|
@@ -65,6 +62,24 @@ class PuppetStrings::Yard::CodeObjects::DataType < PuppetStrings::Yard::CodeObje
|
|
65
62
|
docstring.tags(:param).map { |tag| [tag.name, defaults[tag.name]] }
|
66
63
|
end
|
67
64
|
|
65
|
+
def add_function(name, return_type, parameter_types)
|
66
|
+
meth_obj = YARD::CodeObjects::MethodObject.new(self, name, :class)
|
67
|
+
|
68
|
+
# Add return tag
|
69
|
+
meth_obj.add_tag(YARD::Tags::Tag.new(:return, '', return_type))
|
70
|
+
|
71
|
+
# Add parameters
|
72
|
+
parameter_types.each_with_index do |param_type, index|
|
73
|
+
meth_obj.add_tag(YARD::Tags::Tag.new(:param, '', [param_type], "param#{index + 1}"))
|
74
|
+
end
|
75
|
+
|
76
|
+
self.meths << meth_obj
|
77
|
+
end
|
78
|
+
|
79
|
+
def functions
|
80
|
+
meths
|
81
|
+
end
|
82
|
+
|
68
83
|
# Converts the code object to a hash representation.
|
69
84
|
# @return [Hash] Returns a hash representation of the code object.
|
70
85
|
def to_hash
|
@@ -72,9 +87,16 @@ class PuppetStrings::Yard::CodeObjects::DataType < PuppetStrings::Yard::CodeObje
|
|
72
87
|
hash[:name] = name
|
73
88
|
hash[:file] = file
|
74
89
|
hash[:line] = line
|
75
|
-
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
|
76
|
-
hash[:defaults] = defaults unless defaults.empty?
|
77
|
-
hash[:source] = source unless source
|
90
|
+
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example])
|
91
|
+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
|
92
|
+
hash[:source] = source unless source.nil? || source.empty?
|
93
|
+
hash[:functions] = functions.map do |func|
|
94
|
+
{
|
95
|
+
name: func.name,
|
96
|
+
signature: func.signature,
|
97
|
+
docstring: PuppetStrings::Yard::Util.docstring_to_hash(func.docstring, %i[param option enum return example])
|
98
|
+
}
|
99
|
+
end
|
78
100
|
hash
|
79
101
|
end
|
80
102
|
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 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
|