diff --git a/lib/ansible/parsing/plugin_docs.py b/lib/ansible/parsing/plugin_docs.py index a1f16106ccf..10111472e35 100644 --- a/lib/ansible/parsing/plugin_docs.py +++ b/lib/ansible/parsing/plugin_docs.py @@ -127,6 +127,7 @@ def read_docstring_from_python_file(filename, verbose=True, ignore_errors=True): """ data = _init_doc_dict() + try: with open(filename, 'rb') as b_module_data: M = ast.parse(b_module_data.read()) @@ -141,8 +142,8 @@ def read_docstring_from_python_file(filename, verbose=True, ignore_errors=True): display.warning("Building documentation, failed to assign id for %s on %s, skipping" % (t, filename)) continue - if theid in DOCSTRING_TO_VAR: - varkey = DOCSTRING_TO_VAR[theid] + if theid in string_to_vars: + varkey = string_to_vars[theid] if isinstance(child.value, ast.Dict): data[varkey] = ast.literal_eval(child.value) else: diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py index 9c0662a164a..8c0bf0207a0 100644 --- a/lib/ansible/plugins/loader.py +++ b/lib/ansible/plugins/loader.py @@ -30,6 +30,7 @@ from ansible.module_utils.common._collections_compat import Mapping from ansible.module_utils.compat.importlib import import_module from ansible.module_utils.six import string_types from ansible.parsing.utils.yaml import from_yaml +from ansible.parsing.yaml.loader import AnsibleLoader from ansible.plugins import get_plugin_class, MODULE_CACHE, PATH_CACHE, PLUGIN_PATH_CACHE from ansible.utils.collection_loader import AnsibleCollectionConfig, AnsibleCollectionRef from ansible.utils.collection_loader._collection_finder import _AnsibleCollectionFinder, _get_collection_metadata diff --git a/lib/ansible/utils/plugin_docs.py b/lib/ansible/utils/plugin_docs.py index 6ce5cea4bc5..f381ac0a65a 100644 --- a/lib/ansible/utils/plugin_docs.py +++ b/lib/ansible/utils/plugin_docs.py @@ -11,7 +11,7 @@ from ansible.release import __version__ as ansible_version from ansible.errors import AnsibleError, AnsibleParserError, AnsiblePluginNotFound from ansible.module_utils.six import string_types from ansible.module_utils.common.text.converters import to_native -from ansible.parsing.plugin_docs import read_docstring +from ansible.parsing.plugin_docs import read_docstring, string_to_vars from ansible.module_utils.common._collections_compat import MutableMapping, MutableSet, MutableSequence from ansible.parsing.yaml.loader import AnsibleLoader @@ -234,7 +234,7 @@ def get_docstring(filename, fragment_loader, verbose=False, ignore_errors=False, data = read_docstring(filename, verbose=verbose, ignore_errors=ignore_errors) for section in FRAGMENTS: - key = DOCSTRING_TO_VAR[section] + key = string_to_vars[section] if data.get(key, False): # add fragments to documentation @@ -281,12 +281,7 @@ def get_versioned_doclink(path): return '(unable to create versioned doc link for path {0}: {1})'.format(path, to_native(ex)) -<<<<<<< HEAD def _find_adjacent(path, plugin, extensions): -======= -def get_pymodule_docs(pymodule, path=None, section=None, floader=None): - ''' faster method that gets docs from loaded python module ''' ->>>>>>> af01693d20 (add path to keep it 'relative') adjacent = Path(path)