@@ -346,6 +346,47 @@ def too_old(added):
346
346
return added_float < TOO_OLD_TO_BE_NOTABLE
347
347
348
348
349
+ def process_options (module , options ):
350
+ option_names = []
351
+
352
+ if options :
353
+ for (k , v ) in iteritems (options ):
354
+ # Error out if there's no description
355
+ if 'description' not in v :
356
+ raise AnsibleError ("Missing required description for parameter '%s' in '%s' " % (k , module ))
357
+
358
+ # Make sure description is a list of lines for later formatting
359
+ if isinstance (v ['description' ], string_types ):
360
+ v ['description' ] = [v ['description' ]]
361
+ elif not isinstance (v ['description' ], (list , tuple )):
362
+ raise AnsibleError ("Invalid type for options['%s']['description']."
363
+ " Must be string or list of strings. Got %s" %
364
+ (k , type (v ['description' ])))
365
+
366
+ # Error out if required isn't a boolean (people have been putting
367
+ # information on when something is required in here. Those need
368
+ # to go in the description instead).
369
+ required_value = v .get ('required' , False )
370
+ if not isinstance (required_value , bool ):
371
+ raise AnsibleError ("Invalid required value '%s' for parameter '%s' in '%s' (must be truthy)" % (required_value , k , module ))
372
+
373
+ # Strip old version_added information for options
374
+ if 'version_added' in v and too_old (v ['version_added' ]):
375
+ del v ['version_added' ]
376
+
377
+ if 'suboptions' in v and v ['suboptions' ]:
378
+ if isinstance (v ['suboptions' ], dict ):
379
+ process_options (module , v ['suboptions' ])
380
+ elif isinstance (v ['suboptions' ][0 ], dict ):
381
+ process_options (module , v ['suboptions' ][0 ])
382
+
383
+ option_names .append (k )
384
+
385
+ option_names .sort ()
386
+
387
+ return option_names
388
+
389
+
349
390
def process_plugins (module_map , templates , outputname , output_dir , ansible_version , plugin_type ):
350
391
for module_index , module in enumerate (module_map ):
351
392
@@ -417,38 +458,7 @@ def process_plugins(module_map, templates, outputname, output_dir, ansible_versi
417
458
if too_old (added ):
418
459
del doc ['version_added' ]
419
460
420
- option_names = []
421
-
422
- if 'options' in doc and doc ['options' ]:
423
- for (k , v ) in iteritems (doc ['options' ]):
424
- # Error out if there's no description
425
- if 'description' not in doc ['options' ][k ]:
426
- raise AnsibleError ("Missing required description for parameter '%s' in '%s' " % (k , module ))
427
-
428
- # Make sure description is a list of lines for later formatting
429
- if isinstance (doc ['options' ][k ]['description' ], string_types ):
430
- doc ['options' ][k ]['description' ] = [doc ['options' ][k ]['description' ]]
431
- elif not isinstance (doc ['options' ][k ]['description' ], (list , tuple )):
432
- raise AnsibleError ("Invalid type for options['%s']['description']."
433
- " Must be string or list of strings. Got %s" %
434
- (k , type (doc ['options' ][k ]['description' ])))
435
-
436
- # Error out if required isn't a boolean (people have been putting
437
- # information on when something is required in here. Those need
438
- # to go in the description instead).
439
- required_value = doc ['options' ][k ].get ('required' , False )
440
- if not isinstance (required_value , bool ):
441
- raise AnsibleError ("Invalid required value '%s' for parameter '%s' in '%s' (must be truthy)" % (required_value , k , module ))
442
-
443
- # Strip old version_added information for options
444
- if 'version_added' in doc ['options' ][k ] and too_old (doc ['options' ][k ]['version_added' ]):
445
- del doc ['options' ][k ]['version_added' ]
446
-
447
- option_names .append (k )
448
-
449
- option_names .sort ()
450
-
451
- doc ['option_keys' ] = option_names
461
+ doc ['option_keys' ] = process_options (module , doc .get ('options' ))
452
462
doc ['filename' ] = fname
453
463
doc ['source' ] = module_map [module ]['source' ]
454
464
doc ['docuri' ] = doc ['module' ].replace ('_' , '-' )
0 commit comments