diff --git a/docs/templates/cli_rst.j2 b/docs/templates/cli_rst.j2 index 0e4c0f168313bd..8f5a8db3379a9d 100644 --- a/docs/templates/cli_rst.j2 +++ b/docs/templates/cli_rst.j2 @@ -158,4 +158,4 @@ Ansible is released under the terms of the GPLv3+ License. See also ======== -{% for other in cli_bin_name_list|sort %}:manpage:`{{other}}(1)`, {% endfor %} +{% for other in cli_bin_name_list|sort %}{% if other != cli_name %}:manpage:`{{other}}(1)`{% if not loop.last %}, {% endif %}{% endif %}{% endfor %} diff --git a/hacking/build_library/build_ansible/command_plugins/generate_man.py b/hacking/build_library/build_ansible/command_plugins/generate_man.py index a8c668a0c05a06..a155b28f9b842b 100644 --- a/hacking/build_library/build_ansible/command_plugins/generate_man.py +++ b/hacking/build_library/build_ansible/command_plugins/generate_man.py @@ -127,6 +127,7 @@ def opts_docs(cli_class_name, cli_module_name): pass # base/common cli info + cli_options = opt_doc_list(cli.parser) docs = { 'cli': cli_module_name, 'cli_name': cli_name, @@ -135,22 +136,18 @@ def opts_docs(cli_class_name, cli_module_name): 'long_desc': trim_docstring(cli.__doc__), 'actions': {}, 'content_depth': 2, + 'options': cli_options, + 'arguments': getattr(cli, 'ARGUMENTS', None), } option_info = {'option_names': [], - 'options': [], + 'options': cli_options, 'groups': []} - for extras in ('ARGUMENTS'): - if hasattr(cli, extras): - docs[extras.lower()] = getattr(cli, extras) - - common_opts = opt_doc_list(cli.parser) groups_info = get_option_groups(cli.parser) shared_opt_names = [] - for opt in common_opts: + for opt in cli_options: shared_opt_names.extend(opt.get('options', [])) - option_info['options'] = common_opts option_info['option_names'] = shared_opt_names option_info['groups'].extend(groups_info) @@ -211,7 +208,6 @@ def get_actions(parser, docs): action_depth = get_actions(cli.parser, docs) docs['content_depth'] = action_depth + 1 - docs['options'] = opt_doc_list(cli.parser) return docs @@ -292,11 +288,14 @@ def main(args): # add rest to vars tvars = allvars[cli_name] - tvars['cli_list'] = cli_list tvars['cli_bin_name_list'] = cli_bin_name_list tvars['cli'] = cli_name - if '-i' in tvars['options']: + if '-i' in tvars['option_names']: + tvars['inventory'] = True print('uses inventory') + if '-M' in tvars['option_names']: + tvars['library'] = True + print('uses library') manpage = template.render(tvars) filename = os.path.join(output_dir, doc_name_formats[output_format] % tvars['cli_name']) diff --git a/packaging/pep517_backend/_templates/man.j2 b/packaging/pep517_backend/_templates/man.j2 index 8bd3644cbd544e..9a8cb1d7931d4b 100644 --- a/packaging/pep517_backend/_templates/man.j2 +++ b/packaging/pep517_backend/_templates/man.j2 @@ -1,6 +1,5 @@ -{% set name = ('ansible' if cli == 'adhoc' else 'ansible-%s' % cli) -%} -{{name}} -{{ '=' * ( name|length|int ) }} +{{ cli_name }} +{{ '=' * ( cli_name|length|int ) }} {{ '-' * ( short_desc|default('')|string|length|int ) }} {{short_desc|default('')}} @@ -14,7 +13,7 @@ SYNOPSIS -------- -{{ usage|replace('%prog', name) }} +{{ usage|replace('%prog', cli_name) }} DESCRIPTION @@ -120,7 +119,7 @@ Ansible is released under the terms of the GPLv3 license. SEE ALSO -------- -{% for other in cli_list|sort %}{% if other != cli %}**ansible{% if other != 'adhoc' %}-{{other}}{% endif %}** (1){% if not loop.last %}, {% endif %}{% endif %}{% endfor %} +{% for other in cli_bin_name_list|sort %}{% if other != cli_name %}**{{ other }}** (1){% if not loop.last %}, {% endif %}{% endif %}{% endfor %} Extensive documentation is available in the documentation site: .