From 8e00447aefa7f585f6d17ce8e8e0e820fb48f348 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 28 Sep 2020 18:36:00 +0200 Subject: [PATCH] ansible-doc: show correct plugin name (#71966) (#71984) (cherry picked from commit 0c3a9c7ae609986c6ce2ab750e5d68abaeb30b81) --- changelogs/fragments/71966-ansible-doc-plugin-name.yml | 2 ++ lib/ansible/cli/doc.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/71966-ansible-doc-plugin-name.yml diff --git a/changelogs/fragments/71966-ansible-doc-plugin-name.yml b/changelogs/fragments/71966-ansible-doc-plugin-name.yml new file mode 100644 index 00000000000..19837c21e74 --- /dev/null +++ b/changelogs/fragments/71966-ansible-doc-plugin-name.yml @@ -0,0 +1,2 @@ +bugfixes: +- "ansible-doc - properly show plugin name when ``name:`` is used instead of ``:`` (https://github.com/ansible/ansible/pull/71966)." diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index bae37764b6a..061b406853a 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -385,7 +385,7 @@ class DocCLI(CLI): text = DocCLI.get_snippet_text(doc) else: try: - text = DocCLI.get_man_text(doc, collection_name) + text = DocCLI.get_man_text(doc, collection_name, plugin_type) except Exception as e: raise AnsibleError("Unable to retrieve documentation from '%s' due to: %s" % (plugin, to_native(e))) @@ -619,7 +619,7 @@ class DocCLI(CLI): text.append('') @staticmethod - def get_man_text(doc, collection_name=''): + def get_man_text(doc, collection_name='', plugin_type=''): # Create a copy so we don't modify the original doc = dict(doc) @@ -629,7 +629,7 @@ class DocCLI(CLI): pad = display.columns * 0.20 limit = max(display.columns - int(pad), 70) - plugin_name = doc.get(context.CLIARGS['type'], doc.get('plugin_type')) + plugin_name = doc.get(context.CLIARGS['type'], doc.get('name')) or doc.get('plugin_type') or plugin_type if collection_name: plugin_name = '%s.%s' % (collection_name, plugin_name)