From 698b8d64fc3a847758aa2aa96ea9bf0af55ffcce Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Sat, 31 May 2025 00:12:45 +0200 Subject: [PATCH] Exclude ansible._protomatter from ansible-doc output by default (#85115) * Exclude ansible._protomatter from ansible-doc output by default * Added changelog (cherry picked from commit b4741fc49524ade72ab84276e3744c5016382a37) --- changelogs/fragments/ansible-doc-protomatter.yml | 2 ++ lib/ansible/cli/doc.py | 8 +++++++- test/integration/targets/ansible-doc/test.yml | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/ansible-doc-protomatter.yml diff --git a/changelogs/fragments/ansible-doc-protomatter.yml b/changelogs/fragments/ansible-doc-protomatter.yml new file mode 100644 index 00000000000..47e8afdac4f --- /dev/null +++ b/changelogs/fragments/ansible-doc-protomatter.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-doc - Skip listing the internal ``ansible._protomatter`` plugins unless explicitly requested diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index 458d6db4d6d..c5c23120607 100755 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -794,7 +794,13 @@ class DocCLI(CLI, RoleMixin): loader = DocCLI._prep_loader(plugin_type) coll_filter = self._get_collection_filter() - self.plugins.update(list_plugins(plugin_type, coll_filter)) + plugin_list = list_plugins(plugin_type, coll_filter) + + # Remove the internal ansible._protomatter plugins if getting all plugins + if not coll_filter: + plugin_list = {k: v for k, v in plugin_list.items() if not k.startswith('ansible._protomatter.')} + + self.plugins.update(plugin_list) # get appropriate content depending on option if content == 'dir': diff --git a/test/integration/targets/ansible-doc/test.yml b/test/integration/targets/ansible-doc/test.yml index 7139b915609..685a09b0df9 100644 --- a/test/integration/targets/ansible-doc/test.yml +++ b/test/integration/targets/ansible-doc/test.yml @@ -191,3 +191,19 @@ - assert: that: - "'plugin broken_docs has malformed documentation' in r.msg" + + - name: check ansible._protomatter excluded from output by default + command: ansible-doc -t filter --list + register: result + + - assert: + that: + - result.stdout_lines | select("match", "^ansible\\._protomatter\\.") | length == 0 + + - name: check ansible._protomatter is shown when requested + command: ansible-doc ansible._protomatter -t filter --list + register: result + + - assert: + that: + - result.stdout_lines | select("match", "^ansible\\._protomatter\\.") | length == result.stdout_lines | length