puppet-strings 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +18 -3
  3. data/Gemfile +3 -2
  4. data/Rakefile +5 -0
  5. data/lib/puppet-strings.rb +10 -1
  6. data/lib/puppet-strings/describe.rb +68 -0
  7. data/lib/puppet-strings/json.rb +0 -38
  8. data/lib/puppet-strings/markdown/base.rb +18 -16
  9. data/lib/puppet-strings/markdown/templates/function.erb +26 -0
  10. data/lib/puppet-strings/markdown/templates/resource_type.erb +4 -0
  11. data/lib/puppet-strings/tasks/generate.rb +7 -1
  12. data/lib/puppet-strings/version.rb +1 -1
  13. data/lib/puppet-strings/yard/code_objects/class.rb +1 -1
  14. data/lib/puppet-strings/yard/code_objects/defined_type.rb +1 -1
  15. data/lib/puppet-strings/yard/code_objects/function.rb +3 -3
  16. data/lib/puppet-strings/yard/code_objects/plan.rb +1 -1
  17. data/lib/puppet-strings/yard/code_objects/provider.rb +1 -1
  18. data/lib/puppet-strings/yard/code_objects/type.rb +3 -2
  19. data/lib/puppet-strings/yard/handlers.rb +1 -0
  20. data/lib/puppet-strings/yard/handlers/ruby/base.rb +11 -0
  21. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +1 -9
  22. data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +1 -9
  23. data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +1 -1
  24. data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +130 -0
  25. data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +56 -0
  26. data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +3 -115
  27. data/lib/puppet-strings/yard/parsers/json/parser.rb +3 -1
  28. data/lib/puppet-strings/yard/tags/overload_tag.rb +1 -1
  29. data/lib/puppet-strings/yard/util.rb +48 -0
  30. data/lib/puppet/face/strings.rb +66 -1
  31. data/spec/fixtures/unit/markdown/output.md +64 -0
  32. data/spec/fixtures/unit/markdown/output_with_plan.md +64 -0
  33. data/spec/spec_helper.rb +1 -0
  34. data/spec/unit/puppet-strings/describe_spec.rb +141 -0
  35. data/spec/unit/puppet-strings/json_spec.rb +65 -11
  36. data/spec/unit/puppet-strings/markdown_spec.rb +13 -0
  37. data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +4 -12
  38. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +1 -1
  39. data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +21 -0
  40. data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +26 -0
  41. data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +5 -3
  42. metadata +7 -6
  43. data/spec/fixtures/unit/json/output.json +0 -660
  44. data/spec/fixtures/unit/json/output_with_plan.json +0 -697
  45. data/spec/fixtures/unit/json/output_without_puppet_function.json +0 -480
@@ -1,480 +0,0 @@
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": "todo",
13
- "text": "Do a thing"
14
- },
15
- {
16
- "tag_name": "note",
17
- "text": "Some note"
18
- },
19
- {
20
- "tag_name": "param",
21
- "text": "First param.",
22
- "types": [
23
- "Integer"
24
- ],
25
- "name": "param1"
26
- },
27
- {
28
- "tag_name": "param",
29
- "text": "Second param.",
30
- "types": [
31
- "Any"
32
- ],
33
- "name": "param2"
34
- },
35
- {
36
- "tag_name": "param",
37
- "text": "Third param.",
38
- "types": [
39
- "String"
40
- ],
41
- "name": "param3"
42
- }
43
- ]
44
- },
45
- "defaults": {
46
- "param3": "hi"
47
- },
48
- "source": "class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {\n}"
49
- }
50
- ],
51
- "defined_types": [
52
- {
53
- "name": "dt",
54
- "file": "(stdin)",
55
- "line": 12,
56
- "docstring": {
57
- "text": "A simple defined type.",
58
- "tags": [
59
- {
60
- "tag_name": "param",
61
- "text": "First param.",
62
- "types": [
63
- "Integer"
64
- ],
65
- "name": "param1"
66
- },
67
- {
68
- "tag_name": "param",
69
- "text": "Second param.",
70
- "types": [
71
- "Any"
72
- ],
73
- "name": "param2"
74
- },
75
- {
76
- "tag_name": "param",
77
- "text": "Third param.",
78
- "types": [
79
- "String"
80
- ],
81
- "name": "param3"
82
- }
83
- ]
84
- },
85
- "defaults": {
86
- "param3": "hi"
87
- },
88
- "source": "define dt(Integer $param1, $param2, String $param3 = hi) {\n}"
89
- }
90
- ],
91
- "resource_types": [
92
- {
93
- "name": "database",
94
- "file": "(stdin)",
95
- "line": 54,
96
- "docstring": {
97
- "text": "An example database server resource type."
98
- },
99
- "properties": [
100
- {
101
- "name": "ensure",
102
- "description": "What state the database should be in.",
103
- "values": [
104
- "present",
105
- "absent",
106
- "up",
107
- "down"
108
- ],
109
- "aliases": {
110
- "up": "present",
111
- "down": "absent"
112
- },
113
- "default": "up"
114
- },
115
- {
116
- "name": "file",
117
- "description": "The database file to use."
118
- },
119
- {
120
- "name": "log_level",
121
- "description": "The log level to use.",
122
- "values": [
123
- "debug",
124
- "warn",
125
- "error"
126
- ],
127
- "default": "warn"
128
- }
129
- ],
130
- "parameters": [
131
- {
132
- "name": "address",
133
- "description": "The database server name.",
134
- "isnamevar": true
135
- },
136
- {
137
- "name": "encryption_key",
138
- "description": "The encryption key to use."
139
- },
140
- {
141
- "name": "encrypt",
142
- "description": "Whether or not to encrypt the database.",
143
- "values": [
144
- "true",
145
- "false",
146
- "yes",
147
- "no"
148
- ],
149
- "default": "false"
150
- }
151
- ],
152
- "features": [
153
- {
154
- "name": "encryption",
155
- "description": "The provider supports encryption."
156
- }
157
- ]
158
- }
159
- ],
160
- "providers": [
161
- {
162
- "name": "linux",
163
- "type_name": "database",
164
- "file": "(stdin)",
165
- "line": 43,
166
- "docstring": {
167
- "text": "An example provider on Linux."
168
- },
169
- "confines": {
170
- "kernel": "Linux",
171
- "osfamily": "RedHat"
172
- },
173
- "features": [
174
- "implements_some_feature",
175
- "some_other_feature"
176
- ],
177
- "defaults": [
178
- [
179
- [
180
- "kernel",
181
- "Linux"
182
- ]
183
- ],
184
- [
185
- [
186
- "osfamily",
187
- "RedHat"
188
- ],
189
- [
190
- "operatingsystemmajrelease",
191
- "7"
192
- ]
193
- ]
194
- ],
195
- "commands": {
196
- "foo": "/usr/bin/foo"
197
- }
198
- }
199
- ],
200
- "puppet_functions": [
201
- {
202
- "name": "func3x",
203
- "file": "(stdin)",
204
- "line": 1,
205
- "type": "ruby3x",
206
- "signatures": [
207
- {
208
- "signature": "func3x(String $first, Any $second)",
209
- "docstring": {
210
- "text": "An example 3.x function.",
211
- "tags": [
212
- {
213
- "tag_name": "param",
214
- "text": "The first parameter.",
215
- "types": [
216
- "String"
217
- ],
218
- "name": "first"
219
- },
220
- {
221
- "tag_name": "param",
222
- "text": "The second parameter.",
223
- "types": [
224
- "Any"
225
- ],
226
- "name": "second"
227
- },
228
- {
229
- "tag_name": "return",
230
- "text": "Returns nothing.",
231
- "types": [
232
- "Undef"
233
- ]
234
- }
235
- ]
236
- }
237
- }
238
- ],
239
- "docstring": {
240
- "text": "An example 3.x function.",
241
- "tags": [
242
- {
243
- "tag_name": "param",
244
- "text": "The first parameter.",
245
- "types": [
246
- "String"
247
- ],
248
- "name": "first"
249
- },
250
- {
251
- "tag_name": "param",
252
- "text": "The second parameter.",
253
- "types": [
254
- "Any"
255
- ],
256
- "name": "second"
257
- },
258
- {
259
- "tag_name": "return",
260
- "text": "Returns nothing.",
261
- "types": [
262
- "Undef"
263
- ]
264
- }
265
- ]
266
- },
267
- "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"
268
- },
269
- {
270
- "name": "func4x",
271
- "file": "(stdin)",
272
- "line": 11,
273
- "type": "ruby4x",
274
- "signatures": [
275
- {
276
- "signature": "func4x(Integer $param1, Any $param2, Optional[Array[String]] $param3)",
277
- "docstring": {
278
- "text": "The first overload.",
279
- "tags": [
280
- {
281
- "tag_name": "param",
282
- "text": "The first parameter.",
283
- "types": [
284
- "Integer"
285
- ],
286
- "name": "param1"
287
- },
288
- {
289
- "tag_name": "param",
290
- "text": "The second parameter.",
291
- "types": [
292
- "Any"
293
- ],
294
- "name": "param2"
295
- },
296
- {
297
- "tag_name": "param",
298
- "text": "The third parameter.",
299
- "types": [
300
- "Optional[Array[String]]"
301
- ],
302
- "name": "param3"
303
- },
304
- {
305
- "tag_name": "return",
306
- "text": "Returns nothing.",
307
- "types": [
308
- "Undef"
309
- ]
310
- }
311
- ]
312
- }
313
- },
314
- {
315
- "signature": "func4x(Boolean $param, Callable &$block)",
316
- "docstring": {
317
- "text": "",
318
- "tags": [
319
- {
320
- "tag_name": "param",
321
- "text": "The first parameter.",
322
- "types": [
323
- "Boolean"
324
- ],
325
- "name": "param"
326
- },
327
- {
328
- "tag_name": "param",
329
- "text": "The block parameter.",
330
- "types": [
331
- "Callable"
332
- ],
333
- "name": "&block"
334
- },
335
- {
336
- "tag_name": "return",
337
- "text": "Returns a string.",
338
- "types": [
339
- "String"
340
- ]
341
- }
342
- ]
343
- }
344
- }
345
- ],
346
- "docstring": {
347
- "text": "An example 4.x function.",
348
- "tags": [
349
- {
350
- "tag_name": "overload",
351
- "signature": "func4x(Integer $param1, Any $param2, Optional[Array[String]] $param3)",
352
- "docstring": {
353
- "text": "The first overload.",
354
- "tags": [
355
- {
356
- "tag_name": "param",
357
- "text": "The first parameter.",
358
- "types": [
359
- "Integer"
360
- ],
361
- "name": "param1"
362
- },
363
- {
364
- "tag_name": "param",
365
- "text": "The second parameter.",
366
- "types": [
367
- "Any"
368
- ],
369
- "name": "param2"
370
- },
371
- {
372
- "tag_name": "param",
373
- "text": "The third parameter.",
374
- "types": [
375
- "Optional[Array[String]]"
376
- ],
377
- "name": "param3"
378
- },
379
- {
380
- "tag_name": "return",
381
- "text": "Returns nothing.",
382
- "types": [
383
- "Undef"
384
- ]
385
- }
386
- ]
387
- },
388
- "name": "func4x"
389
- },
390
- {
391
- "tag_name": "overload",
392
- "signature": "func4x(Boolean $param, Callable &$block)",
393
- "docstring": {
394
- "text": "",
395
- "tags": [
396
- {
397
- "tag_name": "param",
398
- "text": "The first parameter.",
399
- "types": [
400
- "Boolean"
401
- ],
402
- "name": "param"
403
- },
404
- {
405
- "tag_name": "param",
406
- "text": "The block parameter.",
407
- "types": [
408
- "Callable"
409
- ],
410
- "name": "&block"
411
- },
412
- {
413
- "tag_name": "return",
414
- "text": "Returns a string.",
415
- "types": [
416
- "String"
417
- ]
418
- }
419
- ]
420
- },
421
- "name": "func4x"
422
- }
423
- ]
424
- },
425
- "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"
426
- },
427
- {
428
- "name": "func4x_1",
429
- "file": "(stdin)",
430
- "line": 35,
431
- "type": "ruby4x",
432
- "signatures": [
433
- {
434
- "signature": "func4x_1(Integer $param1)",
435
- "docstring": {
436
- "text": "An example 4.x function with only one signature.",
437
- "tags": [
438
- {
439
- "tag_name": "param",
440
- "text": "The first parameter.",
441
- "types": [
442
- "Integer"
443
- ],
444
- "name": "param1"
445
- },
446
- {
447
- "tag_name": "return",
448
- "text": "Returns nothing.",
449
- "types": [
450
- "Undef"
451
- ]
452
- }
453
- ]
454
- }
455
- }
456
- ],
457
- "docstring": {
458
- "text": "An example 4.x function with only one signature.",
459
- "tags": [
460
- {
461
- "tag_name": "param",
462
- "text": "The first parameter.",
463
- "types": [
464
- "Integer"
465
- ],
466
- "name": "param1"
467
- },
468
- {
469
- "tag_name": "return",
470
- "text": "Returns nothing.",
471
- "types": [
472
- "Undef"
473
- ]
474
- }
475
- ]
476
- },
477
- "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"
478
- }
479
- ]
480
- }