Fix ansible-doc -l ansible.builtin / ansible.legacy (#76235)

pull/76342/head
Richie B2B 3 years ago committed by GitHub
parent c379e61b8b
commit 1b34933414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- ansible-doc - Fix ansible-doc -l ansible.builtin / ansible.legacy not returning anything

@ -595,7 +595,7 @@ class DocCLI(CLI, RoleMixin):
if len(context.CLIARGS['args']) == 1: if len(context.CLIARGS['args']) == 1:
coll_filter = context.CLIARGS['args'][0] coll_filter = context.CLIARGS['args'][0]
if coll_filter in ('', None): if coll_filter in ('ansible.builtin', 'ansible.legacy', '', None):
paths = loader._get_paths_with_context() paths = loader._get_paths_with_context()
for path_context in paths: for path_context in paths:
self.plugin_list.update(DocCLI.find_plugins(path_context.path, path_context.internal, plugin_type)) self.plugin_list.update(DocCLI.find_plugins(path_context.path, path_context.internal, plugin_type))

@ -5,6 +5,7 @@ __metaclass__ = type
import pytest import pytest
from ansible.cli.doc import DocCLI, RoleMixin from ansible.cli.doc import DocCLI, RoleMixin
from ansible.plugins.loader import module_loader
TTY_IFY_DATA = { TTY_IFY_DATA = {
@ -111,3 +112,19 @@ def test_rolemixin__build_doc_no_filter_match():
fqcn, doc = obj._build_doc(role_name, path, collection_name, argspec, entrypoint_filter) fqcn, doc = obj._build_doc(role_name, path, collection_name, argspec, entrypoint_filter)
assert fqcn == '.'.join([collection_name, role_name]) assert fqcn == '.'.join([collection_name, role_name])
assert doc is None assert doc is None
def test_builtin_modules_list():
args = ['ansible-doc', '-l', 'ansible.builtin', '-t', 'module']
obj = DocCLI(args=args)
obj.parse()
result = obj._list_plugins('module', module_loader)
assert len(result) > 0
def test_legacy_modules_list():
args = ['ansible-doc', '-l', 'ansible.legacy', '-t', 'module']
obj = DocCLI(args=args)
obj.parse()
result = obj._list_plugins('module', module_loader)
assert len(result) > 0

Loading…
Cancel
Save