Browse Source

[autohelp] Return options as dicts instead of lists

This patch updates the _format_opt method to return a dict instead of a
list. This makes the RST templates easier to read and maintain.

Change-Id: Ia1b494b8ec8ed1e523ebe7198bcba00594e21ac5
tags/1.6.0
Gauvain Pocentek 2 years ago
parent
commit
53de7deb1c

+ 7
- 5
autogenerate_config_docs/autohelp.py View File

@@ -467,11 +467,13 @@ def _format_opt(option):
flags.append(('Mutable', 'This option can be changed without'
' restarting.'))

return (option.dest,
opt_type,
_sanitize_default(option),
help_text,
flags)
return {
'name': option.dest,
'type': opt_type,
'default': _sanitize_default(option),
'help': help_text,
'flags': flags
}


def write_files(package_name, options, target):

+ 6
- 6
autogenerate_config_docs/templates/autohelp-category.rst.j2 View File

@@ -22,20 +22,20 @@
-
{% for item in items[loop.index0] %}

{% if item[2] is equalto '' %}
* - ``{{ item[0] }}`` =
{% if item['default'] is equalto '' %}
* - ``{{ item['name'] }}`` =
{% else %}
* - ``{{ item[0] }}`` = ``{{ item[2] }}``
* - ``{{ item['name'] }}`` = ``{{ item['default'] }}``
{% endif %}
{% for paragraph in item[3] %}
{% for paragraph in item['help'] %}

{% if loop.first %}
- ({{ item [1] }}) {{ paragraph }}
- ({{ item['type'] }}) {{ paragraph }}
{% else %}
{{ paragraph }}
{% endif %}
{% endfor %}
{% for flagname, flagdesc in item[4] %}
{% for flagname, flagdesc in item['flags'] %}

- **{{ flagname }}**


+ 6
- 6
autogenerate_config_docs/templates/autohelp-group.rst.j2 View File

@@ -18,20 +18,20 @@
- Description
{% for item in items %}

{% if item[2] is equalto '' %}
* - ``{{ item[0] }}`` =
{% if item['default'] is equalto '' %}
* - ``{{ item['name'] }}`` =
{% else %}
* - ``{{ item[0] }}`` = ``{{ item[2] }}``
* - ``{{ item['name'] }}`` = ``{{ item['default'] }}``
{% endif %}
{% for paragraph in item[3] %}
{% for paragraph in item['help'] %}

{% if loop.first %}
- ({{ item [1] }}) {{ paragraph }}
- ({{ item['type'] }}) {{ paragraph }}
{% else %}
{{ paragraph }}
{% endif %}
{% endfor %}
{% for flagname, flagdesc in item[4] %}
{% for flagname, flagdesc in item['flags'] %}

- **{{ flagname }}**


Loading…
Cancel
Save