diff options
author | Zhikang Zhang <zzhang63@ncsu.edu> | 2018-08-13 16:47:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-13 16:47:12 -0400 |
commit | cda3b53035ed0effda6bea215ed6230bf6c49c7b (patch) | |
tree | e55914862db66c35f1fe5e675a82c267afc0a7ba /docs/bin | |
parent | 26a1c534be1eeff28ab7358e8d2d5f0dcb196267 (diff) | |
download | ansible-cda3b53035ed0effda6bea215ed6230bf6c49c7b.tar.gz |
make doc templates not case sensitive for the default value (#41158)
Diffstat (limited to 'docs/bin')
-rwxr-xr-x | docs/bin/plugin_formatter.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/bin/plugin_formatter.py b/docs/bin/plugin_formatter.py index 03639b3c6d..b4eed26caf 100755 --- a/docs/bin/plugin_formatter.py +++ b/docs/bin/plugin_formatter.py @@ -51,6 +51,7 @@ from six import iteritems, string_types from ansible.errors import AnsibleError from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils.common.collections import is_sequence +from ansible.module_utils.parsing.convert_bool import boolean from ansible.plugins.loader import fragment_loader from ansible.utils import plugin_docs from ansible.utils.display import Display @@ -159,6 +160,17 @@ def rst_xline(width, char="="): test_list = partial(is_sequence, include_strings=False) +def normalize_options(value): + """Normalize boolean option value.""" + + if value.get('type') == 'bool' and 'default' in value: + try: + value['default'] = boolean(value['default'], strict=True) + except TypeError: + pass + return value + + def write_data(text, output_dir, outputname, module=None): ''' dumps module output to a file or the screen, as requested ''' @@ -274,6 +286,16 @@ def get_plugin_info(module_dir, limit_to=None, verbose=False): # use ansible core library to parse out doc metadata YAML and plaintext examples doc, examples, returndocs, metadata = plugin_docs.get_docstring(module_path, fragment_loader, verbose=verbose) + if 'options' in doc and doc['options'] is None: + display.error("*** ERROR: DOCUMENTATION.options must be a dictionary/hash when used. ***") + pos = getattr(doc, "ansible_pos", None) + if pos is not None: + display.error("Module position: %s, %d, %d" % doc.ansible_pos) + doc['options'] = dict() + + for key, opt in doc.get('options', {}).items(): + doc['options'][key] = normalize_options(opt) + # save all the information module_info[module] = {'path': module_path, 'source': os.path.relpath(module_path, module_dir), |