From 84b8f674a7df5538044e35481660acbd49f2e41c Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 28 Nov 2017 12:05:19 -0600 Subject: [PATCH] Fix py3 docs build (#33345) * Open file in binary mode to support py3 writes using bytes * Update sort filter to use an attribute, so that py3 can sort dictionaries --- docs/bin/dump_config.py | 2 +- docs/templates/cli_rst.j2 | 2 +- docs/templates/config.rst.j2 | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/bin/dump_config.py b/docs/bin/dump_config.py index bc3891d5c5e..ffb37a48dc6 100755 --- a/docs/bin/dump_config.py +++ b/docs/bin/dump_config.py @@ -62,7 +62,7 @@ def main(args): output_name = os.path.join(output_dir, template_file.replace('.j2', '')) temp_vars = {'config_options': config_options} - with open(output_name, 'w') as f: + with open(output_name, 'wb') as f: f.write(template.render(temp_vars).encode('utf-8')) return 0 diff --git a/docs/templates/cli_rst.j2 b/docs/templates/cli_rst.j2 index 15ca2b34617..6b9d74f1826 100644 --- a/docs/templates/cli_rst.j2 +++ b/docs/templates/cli_rst.j2 @@ -77,7 +77,7 @@ Actions {% if actions[action]['options'] %} -{% for option in actions[action]['options']|sort %} +{% for option in actions[action]['options']|sort(attribute='options') %} .. option:: {% for switch in option['options'] if switch in actions[action]['option_names'] %}{{switch}} {% if option['arg'] %} <{{option['arg']}}>{% endif %}{% if not loop.last %}, {% endif %}{% endfor %} {{ (option['desc']) }} diff --git a/docs/templates/config.rst.j2 b/docs/templates/config.rst.j2 index 3df3bf0ba63..2fc1d322fe0 100644 --- a/docs/templates/config.rst.j2 +++ b/docs/templates/config.rst.j2 @@ -65,11 +65,11 @@ you can use the command line utility mentioned above (`ansible-config`) to brows {% if config['version_added'] %} :Version Added: {{config['version_added']}} {% endif %} -{% for ini_map in config['ini']|sort %} +{% for ini_map in config['ini']|sort(attribute='section') %} :Ini Section: {{ini_map['section']}} :Ini Key: {{ini_map['key']}} {% endfor %} -{% for env_var_map in config['env']|sort %} +{% for env_var_map in config['env']|sort(attribute='name') %} :Environment: :envvar:`{{env_var_map['name']}}` {% endfor %} {% if config['deprecated'] %}