Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-2.14] Fix misrendered sections in manpage generation #81380

Merged
merged 1 commit into from Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/templates/cli_rst.j2
Expand Up @@ -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 %}
21 changes: 10 additions & 11 deletions hacking/build_library/build_ansible/command_plugins/generate_man.py
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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'])
Expand Down
9 changes: 4 additions & 5 deletions 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('')}}
Expand All @@ -14,7 +13,7 @@

SYNOPSIS
--------
{{ usage|replace('%prog', name) }}
{{ usage|replace('%prog', cli_name) }}


DESCRIPTION
Expand Down Expand Up @@ -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:
<https://docs.ansible.com>.
Expand Down