[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
This commit is contained in:
Gauvain Pocentek 2017-04-28 17:40:27 +02:00
parent 121ddfebd1
commit 53de7deb1c
3 changed files with 19 additions and 17 deletions

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):

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 }}**

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 }}**