@@ -258,4 +258,86 @@ def parse_data_type_content
258
258
259
259
MARKDOWN
260
260
end
261
+
262
+ it 'renders single-line data types with inline code' do
263
+ expect ( YARD ::Parser ::SourceParser . parse_string ( <<~'PUPPET' , :puppet ) . enumerator . length ) . to eq ( 1 )
264
+ # @summary it’s for testing
265
+ type MyEnum = Enum[a, b]
266
+ PUPPET
267
+
268
+ expect ( described_class . generate ) . to match ( %r{^Alias of `Enum\[ a, b\] `$} )
269
+ end
270
+
271
+ it 'renders multi-line data types with inline code' do
272
+ expect ( YARD ::Parser ::SourceParser . parse_string ( <<~'PUPPET' , :puppet ) . enumerator . length ) . to eq ( 1 )
273
+ # summary Test Type
274
+ #
275
+ type Test_module::Test_type = Hash[
276
+ Pattern[/^[a-z][a-z0-9_-]*$/],
277
+ Struct[
278
+ {
279
+ param1 => String[1],
280
+ param2 => Stdlib::Absolutepath,
281
+ paramX => Boolean,
282
+ }
283
+ ]
284
+ ]
285
+ PUPPET
286
+
287
+ expect ( described_class . generate ) . to include ( <<~'MARKDOWN' )
288
+ Alias of
289
+
290
+ ```puppet
291
+ Hash[Pattern[/^[a-z][a-z0-9_-]*$/], Struct[
292
+ {
293
+ param1 => String[1],
294
+ param2 => Stdlib::Absolutepath,
295
+ paramX => Boolean,
296
+ }
297
+ ]]
298
+ ```
299
+ MARKDOWN
300
+ end
301
+
302
+ it 'renders single-line default values with inline code' do
303
+ expect ( YARD ::Parser ::SourceParser . parse_string ( <<~'PUPPET' , :puppet ) . enumerator . length ) . to eq ( 1 )
304
+ # @summary Test
305
+ class myclass (
306
+ String $os = 'linux',
307
+ ) {
308
+ }
309
+ PUPPET
310
+
311
+ expect ( described_class . generate ) . to include ( <<~'MARKDOWN' )
312
+ Default value: `'linux'`
313
+ MARKDOWN
314
+ end
315
+
316
+ it 'renders multi-line default values with a code block' do
317
+ skip ( 'Broken by https://tickets.puppetlabs.com/browse/PUP-11632' )
318
+
319
+ expect ( YARD ::Parser ::SourceParser . parse_string ( <<~'PUPPET' , :puppet ) . enumerator . length ) . to eq ( 1 )
320
+ # @summary Test
321
+ class myclass (
322
+ String $os = $facts['kernel'] ? {
323
+ 'Linux' => 'linux',
324
+ 'Darwin' => 'darwin',
325
+ default => $facts['kernel'],
326
+ },
327
+ ) {
328
+ }
329
+ PUPPET
330
+
331
+ expect ( described_class . generate ) . to include ( <<~'MARKDOWN' )
332
+ Default value:
333
+
334
+ ```puppet
335
+ $facts['kernel'] ? {
336
+ 'Linux' => 'linux',
337
+ 'Darwin' => 'darwin',
338
+ default => $facts['kernel']
339
+ }
340
+ ```
341
+ MARKDOWN
342
+ end
261
343
end
0 commit comments