puppet-strings 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/CONTRIBUTING.md +3 -7
  4. data/JSON.md +126 -8
  5. data/README.md +16 -498
  6. data/lib/puppet-strings.rb +6 -0
  7. data/lib/puppet-strings/json.rb +2 -0
  8. data/lib/puppet-strings/markdown.rb +6 -1
  9. data/lib/puppet-strings/markdown/puppet_plan.rb +14 -0
  10. data/lib/puppet-strings/markdown/puppet_plans.rb +37 -0
  11. data/lib/puppet-strings/markdown/puppet_task.rb +24 -0
  12. data/lib/puppet-strings/markdown/puppet_tasks.rb +34 -0
  13. data/lib/puppet-strings/markdown/table_of_contents.rb +3 -1
  14. data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +8 -5
  15. data/lib/puppet-strings/markdown/templates/function.erb +2 -3
  16. data/lib/puppet-strings/markdown/templates/puppet_task.erb +28 -0
  17. data/lib/puppet-strings/markdown/templates/resource_type.erb +9 -5
  18. data/lib/puppet-strings/markdown/templates/table_of_contents.erb +5 -0
  19. data/lib/puppet-strings/monkey_patches/display_object_command.rb +11 -0
  20. data/lib/puppet-strings/yard.rb +15 -1
  21. data/lib/puppet-strings/yard/code_objects.rb +2 -0
  22. data/lib/puppet-strings/yard/code_objects/plan.rb +56 -0
  23. data/lib/puppet-strings/yard/code_objects/task.rb +70 -0
  24. data/lib/puppet-strings/yard/handlers.rb +6 -0
  25. data/lib/puppet-strings/yard/handlers/json/base.rb +5 -0
  26. data/lib/puppet-strings/yard/handlers/json/task_handler.rb +31 -0
  27. data/lib/puppet-strings/yard/handlers/puppet/base.rb +1 -1
  28. data/lib/puppet-strings/yard/handlers/puppet/class_handler.rb +1 -1
  29. data/lib/puppet-strings/yard/handlers/puppet/defined_type_handler.rb +1 -1
  30. data/lib/puppet-strings/yard/handlers/puppet/function_handler.rb +1 -1
  31. data/lib/puppet-strings/yard/handlers/puppet/plan_handler.rb +27 -0
  32. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +4 -1
  33. data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +12 -2
  34. data/lib/puppet-strings/yard/parsers.rb +4 -0
  35. data/lib/puppet-strings/yard/parsers/json/parser.rb +33 -0
  36. data/lib/puppet-strings/yard/parsers/json/task_statement.rb +35 -0
  37. data/lib/puppet-strings/yard/parsers/puppet/parser.rb +11 -0
  38. data/lib/puppet-strings/yard/parsers/puppet/statement.rb +14 -0
  39. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_plan.erb +9 -0
  40. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_task.erb +9 -0
  41. data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +18 -0
  42. data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +42 -2
  43. data/lib/puppet-strings/yard/templates/default/puppet_plan/html/box_info.erb +10 -0
  44. data/lib/puppet-strings/yard/templates/default/puppet_plan/html/header.erb +1 -0
  45. data/lib/puppet-strings/yard/templates/default/puppet_plan/html/overview.erb +6 -0
  46. data/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb +11 -0
  47. data/lib/puppet-strings/yard/templates/default/puppet_plan/html/source.erb +12 -0
  48. data/lib/puppet-strings/yard/templates/default/puppet_plan/html/summary.erb +4 -0
  49. data/lib/puppet-strings/yard/templates/default/puppet_task/html/box_info.erb +9 -0
  50. data/lib/puppet-strings/yard/templates/default/puppet_task/html/header.erb +1 -0
  51. data/lib/puppet-strings/yard/templates/default/puppet_task/html/input.erb +5 -0
  52. data/lib/puppet-strings/yard/templates/default/puppet_task/html/overview.erb +6 -0
  53. data/lib/puppet-strings/yard/templates/default/puppet_task/html/parameters.erb +16 -0
  54. data/lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb +22 -0
  55. data/lib/puppet-strings/yard/templates/default/puppet_task/html/supports_noop.erb +3 -0
  56. data/lib/puppet-strings/yard/templates/default/tags/setup.rb +3 -1
  57. data/lib/puppet-strings/yard/util.rb +14 -0
  58. data/spec/fixtures/unit/json/output.json +50 -0
  59. data/spec/fixtures/unit/json/output_with_plan.json +689 -0
  60. data/spec/fixtures/unit/markdown/output.md +63 -8
  61. data/spec/fixtures/unit/markdown/output_with_plan.md +472 -0
  62. data/spec/spec_helper.rb +5 -2
  63. data/spec/unit/puppet-strings/json_spec.rb +42 -2
  64. data/spec/unit/puppet-strings/markdown_spec.rb +41 -8
  65. data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +92 -0
  66. data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +124 -0
  67. data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +1 -1
  68. data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +19 -12
  69. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +33 -0
  70. data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +8 -7
  71. data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +70 -0
  72. data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +56 -0
  73. data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +1 -1
  74. data/spec/unit/puppet-strings/yard/util_spec.rb +17 -0
  75. metadata +38 -5
  76. data/MAINTAINERS +0 -17
@@ -0,0 +1,10 @@
1
+ <div class="box_info">
2
+ <dl>
3
+ <dt>Defined in:</dt>
4
+ <dd>
5
+ <%= object.file %><% if object.files.size > 1 %><span class="defines">,<br />
6
+ <%= object.files[1..-1].map {|f| f.first }.join(",<br /> ") %></div>
7
+ <% end %>
8
+ </dd>
9
+ </dl>
10
+ </div>
@@ -0,0 +1 @@
1
+ <h1>Puppet Plan: <%= object.name %></h1>
@@ -0,0 +1,6 @@
1
+ <h2>Overview</h2>
2
+ <div class="docstring">
3
+ <div class="discussion">
4
+ <%= htmlify(object.docstring) %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,11 @@
1
+ # Initializes the template.
2
+ # @return [void]
3
+ def init
4
+ sections :header, :box_info, :summary, :overview, T('tags'), :source
5
+ end
6
+
7
+ # Renders the box_info section.
8
+ # @return [String] Returns the rendered section.
9
+ def box_info
10
+ erb(:box_info)
11
+ end
@@ -0,0 +1,12 @@
1
+ <div class="method_details_list">
2
+ <table class="source_code">
3
+ <tr>
4
+ <td>
5
+ <pre class="lines"><%= "\n\n\n" %><%= h format_lines(object) %></pre>
6
+ </td>
7
+ <td>
8
+ <pre class="code"><span class="info file"># File '<%= h object.file %>'<% if object.line %>, line <%= object.line %><% end %></span><%= "\n\n" %><%= html_syntax_highlight object.source %></pre>
9
+ </td>
10
+ </tr>
11
+ </table>
12
+ </div>
@@ -0,0 +1,4 @@
1
+ <% if object.docstring.has_tag?(:summary) %>
2
+ <h2>Summary</h2>
3
+ <%= object.docstring.tag(:summary).text %>
4
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <div class="box_info">
2
+ <dl>
3
+ <dt>Defined in:</dt>
4
+ <dd>
5
+ <%= object.file %>,<br />
6
+ <%= object.file.gsub('json','rb') %><br/></div>
7
+ </dd>
8
+ </dl>
9
+ </div>
@@ -0,0 +1 @@
1
+ <h1>Puppet Task: <%= object.name %></h1>
@@ -0,0 +1,5 @@
1
+ <% if json['input_method'] || json['supports_noop'] %>
2
+ <div class="tags">
3
+ <p><strong>Supports noop?</strong> <%= json['supports_noop'] ? "true" : "false" %></p>
4
+ </div>
5
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h2>Overview</h2>
2
+ <div class="docstring">
3
+ <div class="discussion">
4
+ <%= description %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,16 @@
1
+ <% if @parameters && !@parameters.empty? %>
2
+ <div class="tags">
3
+ <p class="tag_title"><%= @tag_title %></p>
4
+ <ul>
5
+ <% @parameters.each do |parameter, values| %>
6
+ <li>
7
+ <span class="name"><%= parameter %></span>
8
+ <span class="type">
9
+ <tt>(<%= values['type'] %>)</tt>
10
+ </span>
11
+ <% if values['description'] %> &mdash; <%= values['description'] %><% end %>
12
+ </li>
13
+ <% end %>
14
+ </ul>
15
+ </div>
16
+ <% end %>
@@ -0,0 +1,22 @@
1
+ # Initializes the template.
2
+ # @return [void]
3
+ def init
4
+ sections :header, :box_info, T('tags'), :overview, :input, :parameters
5
+ end
6
+
7
+ def json
8
+ object.statement.json
9
+ end
10
+
11
+ def description
12
+ json['description']
13
+ end
14
+
15
+ # Renders the parameters section.
16
+ # @return [String] Returns the rendered section.
17
+ def parameters
18
+ @parameters = json['parameters'] || []
19
+ @parameters.to_a.sort!
20
+ @tag_title = 'Parameters'
21
+ erb(:parameters)
22
+ end
@@ -0,0 +1,3 @@
1
+ <% if json['supports_noop'] %>
2
+ <strong>Supports noop?</strong> <%= json['supports_noop'] %>
3
+ <% end %>
@@ -5,7 +5,9 @@ def param
5
5
  object.type == :method ||
6
6
  object.type == :puppet_class ||
7
7
  object.type == :puppet_defined_type ||
8
- object.type == :puppet_function
8
+ object.type == :puppet_function ||
9
+ object.type == :puppet_task ||
10
+ object.type == :puppet_plan
9
11
  end
10
12
 
11
13
  # Renders the overload section.
@@ -14,4 +14,18 @@ module PuppetStrings::Yard::Util
14
14
 
15
15
  Puppet::Util::Docs.scrub(str)
16
16
  end
17
+
18
+ # hacksville, usa
19
+ # YARD creates ids in the html with with the style of "label-Module+description", where the markdown
20
+ # we use in the README involves the GitHub-style, which is #module-description. This takes our GitHub-style
21
+ # links and converts them to reference the YARD-style ids.
22
+ # @see https://github.com/octokit/octokit.rb/blob/0f13944e8dbb0210d1e266addd3335c6dc9fe36a/yard/default/layout/html/setup.rb#L5-L14
23
+ # @param [String] data HTML document to convert
24
+ # @return [String] HTML document with links converted
25
+ def self.github_to_yard_links(data)
26
+ data.scan(/href\=\"\#(.+)\"/).each do |bad_link|
27
+ data.gsub!("=\"##{bad_link.first}\"", "=\"#label-#{bad_link.first.capitalize.gsub('-', '+')}\"")
28
+ end
29
+ data
30
+ end
17
31
  end
@@ -598,5 +598,55 @@
598
598
  },
599
599
  "source": "Puppet::Functions.create_function(:func4x_1) do\n # @param param1 The first parameter.\n # @return [Undef] Returns nothing.\n dispatch :foobarbaz do\n param 'Integer', :param1\n end\nend"
600
600
  }
601
+ ],
602
+ "puppet_tasks": [
603
+ {
604
+ "name": "(stdin)",
605
+ "file": "(stdin)",
606
+ "line": 0,
607
+ "docstring": {
608
+ "text": "Allows you to backup your database to local file.",
609
+ "tags": [
610
+ {
611
+ "name": "database",
612
+ "tag_name": "param",
613
+ "text": "Database to connect to",
614
+ "types": [
615
+ "Optional[String[1]]"
616
+ ]
617
+ },
618
+ {
619
+ "name": "user",
620
+ "tag_name": "param",
621
+ "text": "The user",
622
+ "types": [
623
+ "Optional[String[1]]"
624
+ ]
625
+ },
626
+ {
627
+ "name": "password",
628
+ "tag_name": "param",
629
+ "text": "The password",
630
+ "types": [
631
+ "Optional[String[1]]"
632
+ ]
633
+ },
634
+ {
635
+ "name": "sql",
636
+ "tag_name": "param",
637
+ "text": "Path to file you want backup to",
638
+ "types": [
639
+ "String[1]"
640
+ ]
641
+ }
642
+ ]
643
+ },
644
+ "source": "{\n \"description\": \"Allows you to backup your database to local file.\",\n \"input_method\": \"stdin\",\n \"parameters\": {\n \"database\": {\n \"description\": \"Database to connect to\",\n \"type\": \"Optional[String[1]]\"\n },\n \"user\": {\n \"description\": \"The user\",\n \"type\": \"Optional[String[1]]\"\n },\n \"password\": {\n \"description\": \"The password\",\n \"type\": \"Optional[String[1]]\"\n },\n \"sql\": {\n \"description\": \"Path to file you want backup to\",\n \"type\": \"String[1]\"\n }\n }\n}\n",
645
+ "supports_noop": false,
646
+ "input_method": "stdin"
647
+ }
648
+ ],
649
+ "puppet_plans": [
650
+
601
651
  ]
602
652
  }
@@ -0,0 +1,689 @@
1
+ {
2
+ "puppet_classes": [
3
+ {
4
+ "name": "klass",
5
+ "file": "(stdin)",
6
+ "line": 5,
7
+ "inherits": "foo::bar",
8
+ "docstring": {
9
+ "text": "A simple class.",
10
+ "tags": [
11
+ {
12
+ "tag_name": "param",
13
+ "text": "First param.",
14
+ "types": [
15
+ "Integer"
16
+ ],
17
+ "name": "param1"
18
+ },
19
+ {
20
+ "tag_name": "param",
21
+ "text": "Second param.",
22
+ "types": [
23
+ "Any"
24
+ ],
25
+ "name": "param2"
26
+ },
27
+ {
28
+ "tag_name": "param",
29
+ "text": "Third param.",
30
+ "types": [
31
+ "String"
32
+ ],
33
+ "name": "param3"
34
+ }
35
+ ]
36
+ },
37
+ "defaults": {
38
+ "param3": "hi"
39
+ },
40
+ "source": "class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {\n}"
41
+ }
42
+ ],
43
+ "defined_types": [
44
+ {
45
+ "name": "dt",
46
+ "file": "(stdin)",
47
+ "line": 12,
48
+ "docstring": {
49
+ "text": "A simple defined type.",
50
+ "tags": [
51
+ {
52
+ "tag_name": "param",
53
+ "text": "First param.",
54
+ "types": [
55
+ "Integer"
56
+ ],
57
+ "name": "param1"
58
+ },
59
+ {
60
+ "tag_name": "param",
61
+ "text": "Second param.",
62
+ "types": [
63
+ "Any"
64
+ ],
65
+ "name": "param2"
66
+ },
67
+ {
68
+ "tag_name": "param",
69
+ "text": "Third param.",
70
+ "types": [
71
+ "String"
72
+ ],
73
+ "name": "param3"
74
+ }
75
+ ]
76
+ },
77
+ "defaults": {
78
+ "param3": "hi"
79
+ },
80
+ "source": "define dt(Integer $param1, $param2, String $param3 = hi) {\n}"
81
+ }
82
+ ],
83
+ "resource_types": [
84
+ {
85
+ "name": "apt_key",
86
+ "file": "(stdin)",
87
+ "line": 92,
88
+ "docstring": {
89
+ "text": "This type provides Puppet with the capabilities to manage GPG keys needed\nby apt to perform package validation. Apt has it's own GPG keyring that can\nbe manipulated through the `apt-key` command.\n**Autorequires**:\nIf Puppet is given the location of a key file which looks like an absolute\npath this type will autorequire that file.",
90
+ "tags": [
91
+ {
92
+ "tag_name": "summary",
93
+ "text": "Example resource type using the new API."
94
+ },
95
+ {
96
+ "tag_name": "raise",
97
+ "text": "SomeError"
98
+ },
99
+ {
100
+ "tag_name": "example",
101
+ "text": "apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':\n source => 'http://apt.puppetlabs.com/pubkey.gpg'\n}",
102
+ "name": "here's an example"
103
+ }
104
+ ]
105
+ },
106
+ "properties": [
107
+ {
108
+ "name": "ensure",
109
+ "description": "Whether this apt key should be present or absent on the target system.",
110
+ "data_type": "Enum[present, absent]"
111
+ },
112
+ {
113
+ "name": "created",
114
+ "description": "Date the key was created, in ISO format.",
115
+ "data_type": "String"
116
+ }
117
+ ],
118
+ "parameters": [
119
+ {
120
+ "name": "id",
121
+ "description": "The ID of the key you want to manage.",
122
+ "data_type": "Variant[Pattern[/A(0x)?[0-9a-fA-F]{8}Z/], Pattern[/A(0x)?[0-9a-fA-F]{16}Z/], Pattern[/A(0x)?[0-9a-fA-F]{40}Z/]]",
123
+ "isnamevar": true
124
+ }
125
+ ]
126
+ },
127
+ {
128
+ "name": "database",
129
+ "file": "(stdin)",
130
+ "line": 54,
131
+ "docstring": {
132
+ "text": "An example database server resource type."
133
+ },
134
+ "properties": [
135
+ {
136
+ "name": "ensure",
137
+ "description": "What state the database should be in.",
138
+ "values": [
139
+ "present",
140
+ "absent",
141
+ "up",
142
+ "down"
143
+ ],
144
+ "aliases": {
145
+ "up": "present",
146
+ "down": "absent"
147
+ },
148
+ "default": "up"
149
+ },
150
+ {
151
+ "name": "file",
152
+ "description": "The database file to use."
153
+ },
154
+ {
155
+ "name": "log_level",
156
+ "description": "The log level to use.",
157
+ "values": [
158
+ "debug",
159
+ "warn",
160
+ "error"
161
+ ],
162
+ "default": "warn"
163
+ }
164
+ ],
165
+ "parameters": [
166
+ {
167
+ "name": "address",
168
+ "description": "The database server name.",
169
+ "isnamevar": true
170
+ },
171
+ {
172
+ "name": "encryption_key",
173
+ "description": "The encryption key to use."
174
+ },
175
+ {
176
+ "name": "encrypt",
177
+ "description": "Whether or not to encrypt the database.",
178
+ "values": [
179
+ "true",
180
+ "false",
181
+ "yes",
182
+ "no"
183
+ ],
184
+ "default": "false"
185
+ }
186
+ ],
187
+ "features": [
188
+ {
189
+ "name": "encryption",
190
+ "description": "The provider supports encryption."
191
+ }
192
+ ]
193
+ }
194
+ ],
195
+ "providers": [
196
+ {
197
+ "name": "linux",
198
+ "type_name": "database",
199
+ "file": "(stdin)",
200
+ "line": 43,
201
+ "docstring": {
202
+ "text": "An example provider on Linux."
203
+ },
204
+ "confines": {
205
+ "kernel": "Linux",
206
+ "osfamily": "RedHat"
207
+ },
208
+ "features": [
209
+ "implements_some_feature",
210
+ "some_other_feature"
211
+ ],
212
+ "defaults": [
213
+ [
214
+ [
215
+ "kernel",
216
+ "Linux"
217
+ ]
218
+ ],
219
+ [
220
+ [
221
+ "osfamily",
222
+ "RedHat"
223
+ ],
224
+ [
225
+ "operatingsystemmajrelease",
226
+ "7"
227
+ ]
228
+ ]
229
+ ],
230
+ "commands": {
231
+ "foo": "/usr/bin/foo"
232
+ }
233
+ }
234
+ ],
235
+ "puppet_functions": [
236
+ {
237
+ "name": "func",
238
+ "file": "(stdin)",
239
+ "line": 6,
240
+ "type": "puppet",
241
+ "signatures": [
242
+ {
243
+ "signature": "func(Integer $param1, Any $param2, String $param3 = hi)",
244
+ "docstring": {
245
+ "text": "A simple function.",
246
+ "tags": [
247
+ {
248
+ "tag_name": "param",
249
+ "text": "First param.",
250
+ "types": [
251
+ "Integer"
252
+ ],
253
+ "name": "param1"
254
+ },
255
+ {
256
+ "tag_name": "param",
257
+ "text": "Second param.",
258
+ "types": [
259
+ "Any"
260
+ ],
261
+ "name": "param2"
262
+ },
263
+ {
264
+ "tag_name": "param",
265
+ "text": "Third param.",
266
+ "types": [
267
+ "String"
268
+ ],
269
+ "name": "param3"
270
+ },
271
+ {
272
+ "tag_name": "return",
273
+ "text": "Returns nothing.",
274
+ "types": [
275
+ "Undef"
276
+ ]
277
+ }
278
+ ]
279
+ }
280
+ }
281
+ ],
282
+ "docstring": {
283
+ "text": "A simple function.",
284
+ "tags": [
285
+ {
286
+ "tag_name": "param",
287
+ "text": "First param.",
288
+ "types": [
289
+ "Integer"
290
+ ],
291
+ "name": "param1"
292
+ },
293
+ {
294
+ "tag_name": "param",
295
+ "text": "Second param.",
296
+ "types": [
297
+ "Any"
298
+ ],
299
+ "name": "param2"
300
+ },
301
+ {
302
+ "tag_name": "param",
303
+ "text": "Third param.",
304
+ "types": [
305
+ "String"
306
+ ],
307
+ "name": "param3"
308
+ },
309
+ {
310
+ "tag_name": "return",
311
+ "text": "Returns nothing.",
312
+ "types": [
313
+ "Undef"
314
+ ]
315
+ }
316
+ ]
317
+ },
318
+ "defaults": {
319
+ "param3": "hi"
320
+ },
321
+ "source": "function func(Integer $param1, $param2, String $param3 = hi) {\n}"
322
+ },
323
+ {
324
+ "name": "func3x",
325
+ "file": "(stdin)",
326
+ "line": 1,
327
+ "type": "ruby3x",
328
+ "signatures": [
329
+ {
330
+ "signature": "func3x(String $first, Any $second)",
331
+ "docstring": {
332
+ "text": "An example 3.x function.",
333
+ "tags": [
334
+ {
335
+ "tag_name": "param",
336
+ "text": "The first parameter.",
337
+ "types": [
338
+ "String"
339
+ ],
340
+ "name": "first"
341
+ },
342
+ {
343
+ "tag_name": "param",
344
+ "text": "The second parameter.",
345
+ "types": [
346
+ "Any"
347
+ ],
348
+ "name": "second"
349
+ },
350
+ {
351
+ "tag_name": "return",
352
+ "text": "Returns nothing.",
353
+ "types": [
354
+ "Undef"
355
+ ]
356
+ }
357
+ ]
358
+ }
359
+ }
360
+ ],
361
+ "docstring": {
362
+ "text": "An example 3.x function.",
363
+ "tags": [
364
+ {
365
+ "tag_name": "param",
366
+ "text": "The first parameter.",
367
+ "types": [
368
+ "String"
369
+ ],
370
+ "name": "first"
371
+ },
372
+ {
373
+ "tag_name": "param",
374
+ "text": "The second parameter.",
375
+ "types": [
376
+ "Any"
377
+ ],
378
+ "name": "second"
379
+ },
380
+ {
381
+ "tag_name": "return",
382
+ "text": "Returns nothing.",
383
+ "types": [
384
+ "Undef"
385
+ ]
386
+ }
387
+ ]
388
+ },
389
+ "source": "Puppet::Parser::Functions.newfunction(:func3x, doc: <<-DOC\nAn example 3.x function.\n@param [String] first The first parameter.\n@param second The second parameter.\n@return [Undef] Returns nothing.\nDOC\n) do |*args|\nend"
390
+ },
391
+ {
392
+ "name": "func4x",
393
+ "file": "(stdin)",
394
+ "line": 11,
395
+ "type": "ruby4x",
396
+ "signatures": [
397
+ {
398
+ "signature": "func4x(Integer $param1, Any $param2, Optional[Array[String]] $param3)",
399
+ "docstring": {
400
+ "text": "The first overload.",
401
+ "tags": [
402
+ {
403
+ "tag_name": "param",
404
+ "text": "The first parameter.",
405
+ "types": [
406
+ "Integer"
407
+ ],
408
+ "name": "param1"
409
+ },
410
+ {
411
+ "tag_name": "param",
412
+ "text": "The second parameter.",
413
+ "types": [
414
+ "Any"
415
+ ],
416
+ "name": "param2"
417
+ },
418
+ {
419
+ "tag_name": "param",
420
+ "text": "The third parameter.",
421
+ "types": [
422
+ "Optional[Array[String]]"
423
+ ],
424
+ "name": "param3"
425
+ },
426
+ {
427
+ "tag_name": "return",
428
+ "text": "Returns nothing.",
429
+ "types": [
430
+ "Undef"
431
+ ]
432
+ }
433
+ ]
434
+ }
435
+ },
436
+ {
437
+ "signature": "func4x(Boolean $param, Callable &$block)",
438
+ "docstring": {
439
+ "text": "",
440
+ "tags": [
441
+ {
442
+ "tag_name": "param",
443
+ "text": "The first parameter.",
444
+ "types": [
445
+ "Boolean"
446
+ ],
447
+ "name": "param"
448
+ },
449
+ {
450
+ "tag_name": "param",
451
+ "text": "The block parameter.",
452
+ "types": [
453
+ "Callable"
454
+ ],
455
+ "name": "&block"
456
+ },
457
+ {
458
+ "tag_name": "return",
459
+ "text": "Returns a string.",
460
+ "types": [
461
+ "String"
462
+ ]
463
+ }
464
+ ]
465
+ }
466
+ }
467
+ ],
468
+ "docstring": {
469
+ "text": "An example 4.x function.",
470
+ "tags": [
471
+ {
472
+ "tag_name": "overload",
473
+ "signature": "func4x(Integer $param1, Any $param2, Optional[Array[String]] $param3)",
474
+ "docstring": {
475
+ "text": "The first overload.",
476
+ "tags": [
477
+ {
478
+ "tag_name": "param",
479
+ "text": "The first parameter.",
480
+ "types": [
481
+ "Integer"
482
+ ],
483
+ "name": "param1"
484
+ },
485
+ {
486
+ "tag_name": "param",
487
+ "text": "The second parameter.",
488
+ "types": [
489
+ "Any"
490
+ ],
491
+ "name": "param2"
492
+ },
493
+ {
494
+ "tag_name": "param",
495
+ "text": "The third parameter.",
496
+ "types": [
497
+ "Optional[Array[String]]"
498
+ ],
499
+ "name": "param3"
500
+ },
501
+ {
502
+ "tag_name": "return",
503
+ "text": "Returns nothing.",
504
+ "types": [
505
+ "Undef"
506
+ ]
507
+ }
508
+ ]
509
+ },
510
+ "name": "func4x"
511
+ },
512
+ {
513
+ "tag_name": "overload",
514
+ "signature": "func4x(Boolean $param, Callable &$block)",
515
+ "docstring": {
516
+ "text": "",
517
+ "tags": [
518
+ {
519
+ "tag_name": "param",
520
+ "text": "The first parameter.",
521
+ "types": [
522
+ "Boolean"
523
+ ],
524
+ "name": "param"
525
+ },
526
+ {
527
+ "tag_name": "param",
528
+ "text": "The block parameter.",
529
+ "types": [
530
+ "Callable"
531
+ ],
532
+ "name": "&block"
533
+ },
534
+ {
535
+ "tag_name": "return",
536
+ "text": "Returns a string.",
537
+ "types": [
538
+ "String"
539
+ ]
540
+ }
541
+ ]
542
+ },
543
+ "name": "func4x"
544
+ }
545
+ ]
546
+ },
547
+ "source": "Puppet::Functions.create_function(:func4x) do\n # The first overload.\n # @param param1 The first parameter.\n # @param param2 The second parameter.\n # @param param3 The third parameter.\n # @return Returns nothing.\n dispatch :foo do\n param 'Integer', :param1\n param 'Any', :param2\n optional_param 'Array[String]', :param3\n return_type 'Undef'\n end\n\n # @param param The first parameter.\n # @param block The block parameter.\n # @return Returns a string.\n dispatch :other do\n param 'Boolean', :param\n block_param\n return_type 'String'\n end\nend"
548
+ },
549
+ {
550
+ "name": "func4x_1",
551
+ "file": "(stdin)",
552
+ "line": 35,
553
+ "type": "ruby4x",
554
+ "signatures": [
555
+ {
556
+ "signature": "func4x_1(Integer $param1)",
557
+ "docstring": {
558
+ "text": "An example 4.x function with only one signature.",
559
+ "tags": [
560
+ {
561
+ "tag_name": "param",
562
+ "text": "The first parameter.",
563
+ "types": [
564
+ "Integer"
565
+ ],
566
+ "name": "param1"
567
+ },
568
+ {
569
+ "tag_name": "return",
570
+ "text": "Returns nothing.",
571
+ "types": [
572
+ "Undef"
573
+ ]
574
+ }
575
+ ]
576
+ }
577
+ }
578
+ ],
579
+ "docstring": {
580
+ "text": "An example 4.x function with only one signature.",
581
+ "tags": [
582
+ {
583
+ "tag_name": "param",
584
+ "text": "The first parameter.",
585
+ "types": [
586
+ "Integer"
587
+ ],
588
+ "name": "param1"
589
+ },
590
+ {
591
+ "tag_name": "return",
592
+ "text": "Returns nothing.",
593
+ "types": [
594
+ "Undef"
595
+ ]
596
+ }
597
+ ]
598
+ },
599
+ "source": "Puppet::Functions.create_function(:func4x_1) do\n # @param param1 The first parameter.\n # @return [Undef] Returns nothing.\n dispatch :foobarbaz do\n param 'Integer', :param1\n end\nend"
600
+ }
601
+ ],
602
+ "puppet_tasks": [
603
+ {
604
+ "name": "(stdin)",
605
+ "file": "(stdin)",
606
+ "line": 0,
607
+ "docstring": {
608
+ "text": "Allows you to backup your database to local file.",
609
+ "tags": [
610
+ {
611
+ "name": "database",
612
+ "tag_name": "param",
613
+ "text": "Database to connect to",
614
+ "types": [
615
+ "Optional[String[1]]"
616
+ ]
617
+ },
618
+ {
619
+ "name": "user",
620
+ "tag_name": "param",
621
+ "text": "The user",
622
+ "types": [
623
+ "Optional[String[1]]"
624
+ ]
625
+ },
626
+ {
627
+ "name": "password",
628
+ "tag_name": "param",
629
+ "text": "The password",
630
+ "types": [
631
+ "Optional[String[1]]"
632
+ ]
633
+ },
634
+ {
635
+ "name": "sql",
636
+ "tag_name": "param",
637
+ "text": "Path to file you want backup to",
638
+ "types": [
639
+ "String[1]"
640
+ ]
641
+ }
642
+ ]
643
+ },
644
+ "source": "{\n \"description\": \"Allows you to backup your database to local file.\",\n \"input_method\": \"stdin\",\n \"parameters\": {\n \"database\": {\n \"description\": \"Database to connect to\",\n \"type\": \"Optional[String[1]]\"\n },\n \"user\": {\n \"description\": \"The user\",\n \"type\": \"Optional[String[1]]\"\n },\n \"password\": {\n \"description\": \"The password\",\n \"type\": \"Optional[String[1]]\"\n },\n \"sql\": {\n \"description\": \"Path to file you want backup to\",\n \"type\": \"String[1]\"\n }\n }\n}\n",
645
+ "supports_noop": false,
646
+ "input_method": "stdin"
647
+ }
648
+ ],
649
+ "puppet_plans": [
650
+ {
651
+ "name": "plann",
652
+ "file": "(stdin)",
653
+ "line": 5,
654
+ "docstring": {
655
+ "text": "A simple plan.",
656
+ "tags": [
657
+ {
658
+ "tag_name": "param",
659
+ "text": "First param.",
660
+ "types": [
661
+ "String"
662
+ ],
663
+ "name": "param1"
664
+ },
665
+ {
666
+ "tag_name": "param",
667
+ "text": "Second param.",
668
+ "types": [
669
+ "Any"
670
+ ],
671
+ "name": "param2"
672
+ },
673
+ {
674
+ "tag_name": "param",
675
+ "text": "Third param.",
676
+ "types": [
677
+ "Integer"
678
+ ],
679
+ "name": "param3"
680
+ }
681
+ ]
682
+ },
683
+ "defaults": {
684
+ "param3": "1"
685
+ },
686
+ "source": "plan plann(String $param1, $param2, Integer $param3 = 1) {\n}"
687
+ }
688
+ ]
689
+ }