From f9d674fcfd178bc2f9fb6f466b9e891290d2e53f Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 28 Jul 2023 16:24:04 -0700 Subject: [PATCH] Fix command doc lookup in man page generation (#81365) --- changelogs/fragments/missing-doc-func.yml | 2 ++ lib/ansible/cli/galaxy.py | 2 ++ packaging/pep517_backend/_generate_man.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/missing-doc-func.yml diff --git a/changelogs/fragments/missing-doc-func.yml b/changelogs/fragments/missing-doc-func.yml new file mode 100644 index 00000000000..f7642951dd5 --- /dev/null +++ b/changelogs/fragments/missing-doc-func.yml @@ -0,0 +1,2 @@ +bugfixes: + - When generating man pages, use ``func`` to find the command function instead of looking it up by the command name. diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index 81f6df22e7b..9e3ca14640b 100755 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -293,6 +293,7 @@ class GalaxyCLI(CLI): # Add sub parser for the Galaxy collection actions collection = type_parser.add_parser('collection', help='Manage an Ansible Galaxy collection.') + collection.set_defaults(func=self.execute_collection) # to satisfy doc build collection_parser = collection.add_subparsers(metavar='COLLECTION_ACTION', dest='action') collection_parser.required = True self.add_download_options(collection_parser, parents=[common, cache_options]) @@ -305,6 +306,7 @@ class GalaxyCLI(CLI): # Add sub parser for the Galaxy role actions role = type_parser.add_parser('role', help='Manage an Ansible Galaxy role.') + role.set_defaults(func=self.execute_role) # to satisfy doc build role_parser = role.add_subparsers(metavar='ROLE_ACTION', dest='action') role_parser.required = True self.add_init_options(role_parser, parents=[common, force, offline]) diff --git a/packaging/pep517_backend/_generate_man.py b/packaging/pep517_backend/_generate_man.py index e3c76aad1f8..d83a2e993c7 100644 --- a/packaging/pep517_backend/_generate_man.py +++ b/packaging/pep517_backend/_generate_man.py @@ -170,7 +170,7 @@ def opts_docs(cli_class_name, cli_module_name): # docs['actions'][action] = {} # docs['actions'][action]['name'] = action action_info['name'] = action - action_info['desc'] = trim_docstring(getattr(cli, 'execute_%s' % action).__doc__) + action_info['desc'] = trim_docstring(parser.get_default("func").__doc__) # docs['actions'][action]['desc'] = getattr(cli, 'execute_%s' % action).__doc__.strip() action_doc_list = opt_doc_list(parser)