mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
make doc templates not case sensitive for the default value (#41158)
This commit is contained in:
parent
26a1c534be
commit
cda3b53035
2 changed files with 22 additions and 1 deletions
|
@ -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),
|
||||
|
|
|
@ -15,7 +15,6 @@ DOCUMENTATION = '''
|
|||
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.
|
||||
- To disable this behavior, remove C(auto) from the C(INVENTORY_ENABLED) config element.
|
||||
options:
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
|
Loading…
Reference in a new issue