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.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +102 -4
  3. data/COMMITTERS.md +17 -17
  4. data/CONTRIBUTING.md +37 -7
  5. data/README.md +17 -12
  6. data/lib/puppet-strings.rb +5 -3
  7. data/lib/puppet-strings/describe.rb +2 -0
  8. data/lib/puppet-strings/json.rb +2 -0
  9. data/lib/puppet-strings/markdown.rb +12 -10
  10. data/lib/puppet-strings/markdown/base.rb +30 -3
  11. data/lib/puppet-strings/markdown/data_type.rb +18 -0
  12. data/lib/puppet-strings/markdown/data_types.rb +3 -1
  13. data/lib/puppet-strings/markdown/defined_type.rb +2 -0
  14. data/lib/puppet-strings/markdown/defined_types.rb +3 -1
  15. data/lib/puppet-strings/markdown/function.rb +9 -7
  16. data/lib/puppet-strings/markdown/functions.rb +3 -1
  17. data/lib/puppet-strings/markdown/puppet_class.rb +2 -0
  18. data/lib/puppet-strings/markdown/puppet_classes.rb +3 -1
  19. data/lib/puppet-strings/markdown/puppet_plan.rb +2 -0
  20. data/lib/puppet-strings/markdown/puppet_plans.rb +3 -1
  21. data/lib/puppet-strings/markdown/puppet_task.rb +2 -0
  22. data/lib/puppet-strings/markdown/puppet_tasks.rb +3 -1
  23. data/lib/puppet-strings/markdown/resource_type.rb +21 -2
  24. data/lib/puppet-strings/markdown/resource_types.rb +3 -1
  25. data/lib/puppet-strings/markdown/table_of_contents.rb +3 -1
  26. data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +18 -6
  27. data/lib/puppet-strings/markdown/templates/data_type.erb +30 -7
  28. data/lib/puppet-strings/markdown/templates/data_type_function.erb +67 -0
  29. data/lib/puppet-strings/markdown/templates/function.erb +10 -1
  30. data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
  31. data/lib/puppet-strings/markdown/templates/resource_type.erb +35 -13
  32. data/lib/puppet-strings/markdown/templates/table_of_contents.erb +6 -6
  33. data/lib/puppet-strings/monkey_patches/display_object_command.rb +2 -0
  34. data/lib/puppet-strings/tasks.rb +2 -0
  35. data/lib/puppet-strings/tasks/generate.rb +2 -0
  36. data/lib/puppet-strings/tasks/gh_pages.rb +3 -0
  37. data/lib/puppet-strings/version.rb +3 -1
  38. data/lib/puppet-strings/yard.rb +9 -0
  39. data/lib/puppet-strings/yard/code_objects.rb +2 -0
  40. data/lib/puppet-strings/yard/code_objects/base.rb +2 -0
  41. data/lib/puppet-strings/yard/code_objects/class.rb +4 -2
  42. data/lib/puppet-strings/yard/code_objects/data_type.rb +30 -8
  43. data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +2 -0
  44. data/lib/puppet-strings/yard/code_objects/defined_type.rb +4 -2
  45. data/lib/puppet-strings/yard/code_objects/function.rb +8 -5
  46. data/lib/puppet-strings/yard/code_objects/group.rb +3 -0
  47. data/lib/puppet-strings/yard/code_objects/plan.rb +4 -2
  48. data/lib/puppet-strings/yard/code_objects/provider.rb +6 -0
  49. data/lib/puppet-strings/yard/code_objects/task.rb +3 -1
  50. data/lib/puppet-strings/yard/code_objects/type.rb +49 -5
  51. data/lib/puppet-strings/yard/handlers.rb +2 -0
  52. data/lib/puppet-strings/yard/handlers/helpers.rb +2 -0
  53. data/lib/puppet-strings/yard/handlers/json/base.rb +2 -0
  54. data/lib/puppet-strings/yard/handlers/json/task_handler.rb +2 -0
  55. data/lib/puppet-strings/yard/handlers/puppet/base.rb +3 -0
  56. data/lib/puppet-strings/yard/handlers/puppet/class_handler.rb +2 -0
  57. data/lib/puppet-strings/yard/handlers/puppet/data_type_alias_handler.rb +2 -0
  58. data/lib/puppet-strings/yard/handlers/puppet/defined_type_handler.rb +2 -0
  59. data/lib/puppet-strings/yard/handlers/puppet/function_handler.rb +3 -1
  60. data/lib/puppet-strings/yard/handlers/puppet/plan_handler.rb +2 -0
  61. data/lib/puppet-strings/yard/handlers/ruby/base.rb +5 -0
  62. data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +225 -52
  63. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +9 -7
  64. data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +13 -0
  65. data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +4 -1
  66. data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +20 -6
  67. data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +6 -3
  68. data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +18 -1
  69. data/lib/puppet-strings/yard/parsers.rb +2 -0
  70. data/lib/puppet-strings/yard/parsers/json/parser.rb +2 -0
  71. data/lib/puppet-strings/yard/parsers/json/task_statement.rb +2 -0
  72. data/lib/puppet-strings/yard/parsers/puppet/parser.rb +18 -14
  73. data/lib/puppet-strings/yard/parsers/puppet/statement.rb +4 -0
  74. data/lib/puppet-strings/yard/tags.rb +4 -0
  75. data/lib/puppet-strings/yard/tags/enum_tag.rb +14 -0
  76. data/lib/puppet-strings/yard/tags/factory.rb +18 -0
  77. data/lib/puppet-strings/yard/tags/overload_tag.rb +4 -1
  78. data/lib/puppet-strings/yard/tags/parameter_directive.rb +5 -4
  79. data/lib/puppet-strings/yard/tags/property_directive.rb +5 -4
  80. data/lib/puppet-strings/yard/tags/summary_tag.rb +2 -0
  81. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/method_details_list.erb +6 -0
  82. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +9 -1
  83. data/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +1 -1
  84. data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +3 -1
  85. data/lib/puppet-strings/yard/templates/default/tags/html/enum.erb +17 -0
  86. data/lib/puppet-strings/yard/templates/default/tags/setup.rb +6 -0
  87. data/lib/puppet-strings/yard/util.rb +7 -4
  88. data/lib/puppet/application/strings.rb +2 -0
  89. data/lib/puppet/face/strings.rb +4 -1
  90. data/lib/puppet/feature/rgen.rb +2 -0
  91. data/lib/puppet/feature/yard.rb +2 -0
  92. metadata +14 -51
  93. data/Gemfile +0 -47
  94. data/HISTORY.md +0 -218
  95. data/JSON.md +0 -832
  96. data/Rakefile +0 -168
  97. data/codecov.yml +0 -3
  98. data/misc/ANNOUNCEMENT_TEMPLATE.md +0 -40
  99. data/spec/acceptance/emit_json_options_spec.rb +0 -69
  100. data/spec/acceptance/generate_markdown_spec.rb +0 -47
  101. data/spec/acceptance/running_strings_generate_spec.rb +0 -78
  102. data/spec/fixtures/acceptance/modules/test/functions/add.pp +0 -9
  103. data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +0 -5
  104. data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +0 -2
  105. data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +0 -9
  106. data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +0 -15
  107. data/spec/fixtures/acceptance/modules/test/manifests/init.pp +0 -27
  108. data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +0 -27
  109. data/spec/fixtures/acceptance/modules/test/metadata.json +0 -10
  110. data/spec/fixtures/acceptance/modules/test/types/elephant.pp +0 -2
  111. data/spec/fixtures/unit/markdown/output.md +0 -508
  112. data/spec/fixtures/unit/markdown/output_with_data_types.md +0 -553
  113. data/spec/fixtures/unit/markdown/output_with_plan.md +0 -542
  114. data/spec/spec_helper.rb +0 -49
  115. data/spec/spec_helper_acceptance.rb +0 -58
  116. data/spec/spec_helper_acceptance_local.rb +0 -10
  117. data/spec/unit/puppet-strings/describe_spec.rb +0 -141
  118. data/spec/unit/puppet-strings/json_spec.rb +0 -302
  119. data/spec/unit/puppet-strings/markdown/base_spec.rb +0 -146
  120. data/spec/unit/puppet-strings/markdown_spec.rb +0 -357
  121. data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +0 -92
  122. data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +0 -116
  123. data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +0 -217
  124. data/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +0 -65
  125. data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +0 -231
  126. data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +0 -315
  127. data/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +0 -232
  128. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +0 -746
  129. data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +0 -158
  130. data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +0 -235
  131. data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +0 -311
  132. data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +0 -72
  133. data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +0 -56
  134. data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +0 -251
  135. data/spec/unit/puppet-strings/yard/util_spec.rb +0 -48
@@ -1,146 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PuppetStrings::Markdown::Base do
4
- context 'basic class' do
5
- before :each do
6
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
7
- # An overview
8
- # @api private
9
- # @summary A simple class.
10
- # @param param1 First param.
11
- # @param param2 Second param.
12
- # @param param3 Third param.
13
- class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
14
- }
15
- SOURCE
16
- end
17
-
18
- let(:reg) { YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash)[0] }
19
- let(:component) { PuppetStrings::Markdown::Base.new(reg, 'class') }
20
-
21
- describe '#name' do
22
- it 'returns the expected name' do
23
- expect(component.name).to eq 'klass'
24
- end
25
- end
26
-
27
- ['examples',
28
- 'see',
29
- 'since',
30
- 'return_val',
31
- 'return_type',].each do |method|
32
- describe "##{method}" do
33
- it 'returns nil' do
34
- expect(component.method(method.to_sym).call).to be_nil
35
- end
36
- end
37
-
38
- end
39
-
40
- describe '#private?' do
41
- it do
42
- expect(component.private?).to be true
43
- end
44
- end
45
-
46
- describe '#params' do
47
- it 'returns the expected params' do
48
- expect(component.params.size).to eq 3
49
- end
50
- end
51
-
52
- describe '#summary' do
53
- it 'returns the expected summary' do
54
- expect(component.summary).to eq 'A simple class.'
55
- end
56
- end
57
-
58
- describe '#toc_info' do
59
- let(:toc) { component.toc_info }
60
- it 'returns a hash' do
61
- expect(toc).to be_instance_of Hash
62
- end
63
- it 'prefers the summary for :desc' do
64
- expect(toc[:desc]).to eq 'A simple class.'
65
- end
66
- end
67
- end
68
- context 'less basic class' do
69
- before :each do
70
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
71
- # An overview
72
- # It's a longer overview
73
- # Ya know?
74
- # @example A simple example.
75
- # class { 'klass::yeah':
76
- # param1 => 1,
77
- # }
78
- # @param param1 First param.
79
- # @param param2 Second param.
80
- # @param param3 Third param.
81
- class klass::yeah(
82
- Integer $param1,
83
- $param2,
84
- String $param3 = hi
85
- ) inherits foo::bar {
86
-
87
- }
88
- SOURCE
89
- end
90
-
91
- let(:reg) { YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash)[0] }
92
- let(:component) { PuppetStrings::Markdown::Base.new(reg, 'class') }
93
-
94
- describe '#name' do
95
- it 'returns the expected name' do
96
- expect(component.name).to eq 'klass::yeah'
97
- end
98
- end
99
-
100
- ['summary',
101
- 'see',
102
- 'since',
103
- 'return_val',
104
- 'return_type'].each do |method|
105
- describe "##{method}" do
106
- it 'returns nil' do
107
- expect(component.method(method.to_sym).call).to be_nil
108
- end
109
- end
110
- end
111
-
112
- describe '#examples' do
113
- it 'should return one example' do
114
- expect(component.examples.size).to eq 1
115
- end
116
- end
117
-
118
- describe '#params' do
119
- it 'returns the expected params' do
120
- expect(component.params.size).to eq 3
121
- end
122
- end
123
-
124
- describe '#private?' do
125
- it do
126
- expect(component.private?).to be false
127
- end
128
- end
129
-
130
- describe '#toc_info' do
131
- let(:toc) { component.toc_info }
132
- it 'returns a hash' do
133
- expect(toc).to be_instance_of Hash
134
- end
135
- it 'uses overview for :desc in absence of summary' do
136
- expect(toc[:desc]).to eq 'An overview It\'s a longer overview Ya know?'
137
- end
138
- end
139
-
140
- describe '#link' do
141
- it 'returns a valid link' do
142
- expect(component.link).to eq 'klassyeah'
143
- end
144
- end
145
- end
146
- end
@@ -1,357 +0,0 @@
1
- require 'spec_helper'
2
- require 'puppet-strings/markdown'
3
- require 'puppet-strings/markdown/table_of_contents'
4
- require 'tempfile'
5
-
6
- describe PuppetStrings::Markdown do
7
- def parse_shared_content
8
- # Populate the YARD registry with both Puppet and Ruby source
9
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
10
- # An overview for a simple class.
11
- # @summary A simple class.
12
- # @todo Do a thing
13
- # @note some note
14
- # @since 1.0.0
15
- # @see www.puppet.com
16
- # @example This is an example
17
- # class { 'klass':
18
- # param1 => 1,
19
- # param3 => 'foo',
20
- # }
21
- # @example This is another example
22
- # class { 'klass':
23
- # param1 => 1,
24
- # param3 => 'foo',
25
- # }
26
- # @raise SomeError
27
- # @param param1 First param.
28
- # @param param2 Second param.
29
- # @option param2 [String] :opt1 something about opt1
30
- # @option param2 [Hash] :opt2 a hash of stuff
31
- # @param param3 Third param.
32
- #
33
- class klass (
34
- Integer $param1 = 1,
35
- $param2 = undef,
36
- String $param3 = 'hi'
37
- ) inherits foo::bar {
38
- }
39
-
40
- # Overview for class noparams
41
- # @api private
42
- class noparams () {}
43
-
44
- # An overview for a simple defined type.
45
- # @summary A simple defined type.
46
- # @since 1.1.0
47
- # @see www.puppet.com
48
- # @example Here's an example of this type:
49
- # klass::dt { 'foo':
50
- # param1 => 33,
51
- # param4 => false,
52
- # }
53
- # @return shouldn't return squat
54
- # @raise SomeError
55
- # @param param1 First param.
56
- # @param param2 Second param.
57
- # @option param2 [String] :opt1 something about opt1
58
- # @option param2 [Hash] :opt2 a hash of stuff
59
- # @param param3 Third param.
60
- # @param param4 Fourth param.
61
- define klass::dt (
62
- Integer $param1 = 44,
63
- $param2,
64
- String $param3 = 'hi',
65
- Boolean $param4 = true
66
- ) {
67
- }
68
- SOURCE
69
-
70
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :json)
71
- {
72
- "description": "Allows you to backup your database to local file.",
73
- "input_method": "stdin",
74
- "parameters": {
75
- "database": {
76
- "description": "Database to connect to",
77
- "type": "Optional[String[1]]"
78
- },
79
- "user": {
80
- "description": "The user",
81
- "type": "Optional[String[1]]"
82
- },
83
- "password": {
84
- "description": "The password",
85
- "type": "Optional[String[1]]"
86
- },
87
- "sql": {
88
- "description": "Path to file you want backup to",
89
- "type": "String[1]"
90
- }
91
- }
92
- }
93
- SOURCE
94
-
95
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
96
- # A simple Puppet function.
97
- # @param param1 First param.
98
- # @param param2 Second param.
99
- # @param param3 Third param.
100
- # @option param3 [Array] :param3opt Something about this option
101
- # @raise SomeError this is some error
102
- # @return [Undef] Returns nothing.
103
- # @example Test
104
- # $result = func(1, 2)
105
- function func(Integer $param1, $param2, String $param3 = hi) {
106
- }
107
- SOURCE
108
-
109
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby)
110
- # An example 4.x function.
111
- #
112
- # @example Calling the function
113
- # $result = func4x(1, 'foo')
114
- #
115
- # @example Calling the function with all args
116
- # $result = func4x(1, 'foo', ['bar'])
117
- Puppet::Functions.create_function(:func4x) do
118
- # An overview for the first overload.
119
- # @raise SomeError this is some error
120
- # @param param1 The first parameter.
121
- # @param param2 The second parameter.
122
- # @option param2 [String] :option an option
123
- # @option param2 [String] :option2 another option
124
- # @param param3 The third parameter.
125
- # @return Returns nothing.
126
- # @example Calling the function foo
127
- # $result = func4x(1, 'foooo')
128
- #
129
- dispatch :foo do
130
- param 'Integer', :param1
131
- param 'Any', :param2
132
- optional_param 'Array[String]', :param3
133
- return_type 'Undef'
134
- end
135
-
136
- # An overview for the second overload.
137
- # @param param The first parameter.
138
- # @param block The block parameter.
139
- # @return Returns a string.
140
- # @example Calling the function bar
141
- # $result = func4x(1, 'bar', ['foo'])
142
- dispatch :other do
143
- param 'Boolean', :param
144
- block_param
145
- return_type 'String'
146
- end
147
- end
148
-
149
- # An example 4.x function with only one signature.
150
- Puppet::Functions.create_function(:func4x_1) do
151
- # @param param1 The first parameter.
152
- # @return [Undef] Returns nothing.
153
- dispatch :foobarbaz do
154
- param 'Integer', :param1
155
- end
156
- end
157
-
158
- # An example 3.x function
159
- Puppet::Parser::Functions.newfunction(:func3x, doc: <<-DOC
160
- Documentation for an example 3.x function.
161
- @param param1 [String] The first parameter.
162
- @param param2 [Integer] The second parameter.
163
- @return [Undef]
164
- @example Calling the function.
165
- func3x('hi', 10)
166
- DOC
167
- ) do |*args|
168
- #...
169
- end
170
-
171
- Puppet::Type.type(:database).provide :linux do
172
- desc 'An example provider on Linux.'
173
- confine kernel: 'Linux'
174
- confine osfamily: 'RedHat'
175
- defaultfor :kernel => 'Linux'
176
- defaultfor :osfamily => 'RedHat', :operatingsystemmajrelease => '7'
177
- has_feature :implements_some_feature
178
- has_feature :some_other_feature
179
- commands foo: '/usr/bin/foo'
180
- end
181
-
182
- Puppet::Type.newtype(:database) do
183
- desc <<-DESC
184
- An example database server type.
185
- @option opts :foo bar
186
- @raise SomeError
187
- @example here's an example
188
- database { 'foo':
189
- address => 'qux.baz.bar',
190
- }
191
- DESC
192
- feature :encryption, 'The provider supports encryption.', methods: [:encrypt]
193
- ensurable do
194
- desc 'What state the database should be in.'
195
- defaultvalues
196
- aliasvalue(:up, :present)
197
- aliasvalue(:down, :absent)
198
- defaultto :up
199
- end
200
-
201
- newparam(:address) do
202
- isnamevar
203
- desc 'The database server name.'
204
- end
205
-
206
- newparam(:encryption_key, required_features: :encryption) do
207
- desc 'The encryption key to use.'
208
- end
209
-
210
- newparam(:encrypt, :parent => Puppet::Parameter::Boolean) do
211
- desc 'Whether or not to encrypt the database.'
212
- defaultto false
213
- end
214
-
215
- newproperty(:file) do
216
- desc 'The database file to use.'
217
- end
218
-
219
- newproperty(:log_level) do
220
- desc 'The log level to use.'
221
- newvalue(:debug)
222
- newvalue(:warn)
223
- newvalue(:error)
224
- defaultto 'warn'
225
- end
226
- end
227
-
228
- Puppet::ResourceApi.register_type(
229
- name: 'apt_key',
230
- docs: <<-EOS,
231
- @summary Example resource type using the new API.
232
- @raise SomeError
233
- This type provides Puppet with the capabilities to manage GPG keys needed
234
- by apt to perform package validation. Apt has it's own GPG keyring that can
235
- be manipulated through the `apt-key` command.
236
- @example here's an example
237
- apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':
238
- source => 'http://apt.puppetlabs.com/pubkey.gpg'
239
- }
240
-
241
- **Autorequires**:
242
- If Puppet is given the location of a key file which looks like an absolute
243
- path this type will autorequire that file.
244
- EOS
245
- attributes: {
246
- ensure: {
247
- type: 'Enum[present, absent]',
248
- desc: 'Whether this apt key should be present or absent on the target system.'
249
- },
250
- id: {
251
- 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/]]',
252
- behaviour: :namevar,
253
- desc: 'The ID of the key you want to manage.',
254
- },
255
- # ...
256
- created: {
257
- type: 'String',
258
- behaviour: :read_only,
259
- desc: 'Date the key was created, in ISO format.',
260
- },
261
- },
262
- autorequires: {
263
- file: '$source', # will evaluate to the value of the `source` attribute
264
- package: 'apt',
265
- },
266
- )
267
- SOURCE
268
- end
269
-
270
- def parse_plan_content
271
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
272
- # A simple plan.
273
- # @param param1 First param.
274
- # @param param2 Second param.
275
- # @param param3 Third param.
276
- plan plann(String $param1, $param2, Integer $param3 = 1) {
277
- }
278
- SOURCE
279
- end
280
-
281
- def parse_data_type_content
282
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby)
283
- # An example Puppet Data Type in Ruby.
284
- #
285
- # @param param1 A variant parameter.
286
- # @param param2 Optional String parameter.
287
- Puppet::DataTypes.create_type('UnitDataType') do
288
- interface <<-PUPPET
289
- attributes => {
290
- param1 => Variant[Numeric, String[1,2]],
291
- param2 => { type => Optional[String[1]], value => "param2" }
292
- }
293
- PUPPET
294
- end
295
- SOURCE
296
-
297
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
298
- # Documentation for Amodule::SimpleAlias
299
- type Amodule::SimpleAlias = Variant[Numeric,String[1,20]]
300
-
301
- # Documentation for Amodule::ComplexAlias
302
- type Amodule::ComplexAlias = Struct[{
303
- value_type => Optional[ValueType],
304
- merge => Optional[MergeType]
305
- }]
306
- SOURCE
307
- end
308
- let(:baseline_path) { File.join(File.dirname(__FILE__), "../../fixtures/unit/markdown/#{filename}") }
309
- let(:baseline) { File.read(baseline_path) }
310
-
311
- describe 'rendering markdown to a file' do
312
- before(:each) do
313
- parse_shared_content
314
- end
315
-
316
- context 'with common Puppet and ruby content' do
317
- let(:filename) { 'output.md' }
318
-
319
- it 'should output the expected markdown content' do
320
- Tempfile.open('md') do |file|
321
- PuppetStrings::Markdown.render(file.path)
322
- expect(File.read(file.path)).to eq(baseline)
323
- end
324
- end
325
- end
326
-
327
- describe 'with Puppet Plans', :if => TEST_PUPPET_PLANS do
328
- let(:filename) { 'output_with_plan.md' }
329
-
330
- before(:each) do
331
- parse_plan_content
332
- end
333
-
334
- it 'should output the expected markdown content' do
335
- Tempfile.open('md') do |file|
336
- PuppetStrings::Markdown.render(file.path)
337
- expect(File.read(file.path)).to eq(baseline)
338
- end
339
- end
340
- end
341
-
342
- describe 'with Puppet Data Types', :if => TEST_PUPPET_DATATYPES do
343
- let(:filename) { 'output_with_data_types.md' }
344
-
345
- before(:each) do
346
- parse_data_type_content
347
- end
348
-
349
- it 'should output the expected markdown content' do
350
- Tempfile.open('md') do |file|
351
- PuppetStrings::Markdown.render(file.path)
352
- expect(File.read(file.path)).to eq(baseline)
353
- end
354
- end
355
- end
356
- end
357
- end