make doc templates not case sensitive for the default value (#41158)

pull/45463/head
Zhikang Zhang 6 years ago committed by GitHub
parent 26a1c534be
commit cda3b53035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -51,6 +51,7 @@ from six import iteritems, string_types
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils.common.collections import is_sequence 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.plugins.loader import fragment_loader
from ansible.utils import plugin_docs from ansible.utils import plugin_docs
from ansible.utils.display import Display from ansible.utils.display import Display
@ -159,6 +160,17 @@ def rst_xline(width, char="="):
test_list = partial(is_sequence, include_strings=False) 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): def write_data(text, output_dir, outputname, module=None):
''' dumps module output to a file or the screen, as requested ''' ''' 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 # 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) 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 # save all the information
module_info[module] = {'path': module_path, module_info[module] = {'path': module_path,
'source': os.path.relpath(module_path, module_dir), 'source': os.path.relpath(module_path, module_dir),

@ -15,7 +15,6 @@ DOCUMENTATION = '''
C(plugin) key at its root will automatically cause the named plugin to be loaded and executed with that C(plugin) key at its root will automatically cause the named plugin to be loaded and executed with that
config. This effectively provides automatic whitelisting of all installed/accessible inventory plugins. config. This effectively provides automatic whitelisting of all installed/accessible inventory plugins.
- To disable this behavior, remove C(auto) from the C(INVENTORY_ENABLED) config element. - To disable this behavior, remove C(auto) from the C(INVENTORY_ENABLED) config element.
options:
''' '''
EXAMPLES = ''' EXAMPLES = '''

Loading…
Cancel
Save