fix issue with legacy pugins and no docs (#78686)

* fix issue with legacy pugins and no docs
pull/78697/head
Brian Coca 2 years ago committed by GitHub
parent 077e1bfe17
commit 72783837c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- ansible-doc will not traceback when legacy plugins don't have docs nor adjacent file with docs

@ -340,7 +340,8 @@ def get_plugin_docs(plugin, plugin_type, loader, fragment_loader, verbose):
if not docs[0]:
try:
newfile = _find_adjacent(filename, plugin, C.DOC_EXTENSIONS)
docs = get_docstring(newfile, fragment_loader, verbose=verbose, collection_name=collection_name, plugin_type=plugin_type)
if newfile:
docs = get_docstring(newfile, fragment_loader, verbose=verbose, collection_name=collection_name, plugin_type=plugin_type)
except Exception as e:
raise AnsibleParserError('Adjacent file %s did not contain a DOCUMENTATION attribute (%s)' % (plugin, filename), orig_exc=e)

@ -19,4 +19,5 @@ class FilterModule(object):
def filters(self):
return {
'donothing': donothing,
'nodocs': donothing,
}

@ -160,6 +160,9 @@ count=$(ANSIBLE_LIBRARY='./nolibrary' ansible-doc -l ansible.builtin |wc -l)
[ "$(ansible-doc -t filter --playbook-dir ./ donothing| wc -l)" -gt "0" ]
[ "$(ansible-doc -t filter --playbook-dir ./ ansible.legacy.donothing| wc -l)" -gt "0" ]
# no docs and no sidecar
ansible-doc -t filter --playbook-dir ./ nodocs 2>&1| grep -c 'missing documentation' || true
# produce 'sidecar' docs for module
[ "$(ansible-doc -M ./library test_win_module| wc -l)" -gt "0" ]
[ "$(ansible-doc --playbook-dir ./ test_win_module| wc -l)" -gt "0" ]

Loading…
Cancel
Save