Improve default values and choices in module docs (#36901)

* Improve default values and choices in module docs

So currently we show defaults and choices in separate columns.

For each parameter we have
- Mostly empty default and choices cells
- A list of choices and a separate default value
- Only a default value

So there's a lot of space being wasted on empty cells.
We can do this better.

* Improve Parameters section

* Add Choices back into column header

* Ensure the tables spans the complete page width
pull/37211/head
Dag Wieers 7 years ago committed by scottb
parent 0130490faa
commit 6636401246

@ -74,8 +74,8 @@ The below requirements are needed on the local master node that executes this @{
{% if options -%} {% if options -%}
Options Parameters
------- ----------
.. raw:: html .. raw:: html
@ -83,47 +83,55 @@ Options
{# Header of the documentation #} {# Header of the documentation #}
<tr> <tr>
<th class="head"><div class="cell-border">Parameter</div></th> <th class="head"><div class="cell-border">Parameter</div></th>
<th class="head"><div class="cell-border">Default</div></th> <th class="head"><div class="cell-border">Choices/<font color="blue">Defaults</font></div></th>
<th class="head"><div class="cell-border">Choices</div></th>
{% if plugin_type != 'module' %} {% if plugin_type != 'module' %}
<th class="head"><div class="cell-border">Configuration</div></th> <th class="head"><div class="cell-border">Configuration</div></th>
{% endif %} {% endif %}
<th class="head"><div class="cell-border">Comments</div></th> <th class="head" width="100%"><div class="cell-border">Comments</div></th>
</tr> </tr>
{% for key, value in options|dictsort recursive %} {% for key, value in options|dictsort recursive %}
<tr class="return-value-column"> <tr class="return-value-column">
{# parameter name with introduced label #} {# parameter name with required and/or introduced label #}
<td> <td>
<div class="outer-elbow-container"> <div class="outer-elbow-container">
{% for i in range(1, loop.depth) %} {% for i in range(1, loop.depth) %}
<div class="elbow-placeholder"> <div class="elbow-placeholder"></div>
</div>
{% endfor %} {% endfor %}
<div class="elbow-key"> <div class="elbow-key">
<b>@{ key }@</b> <b>@{ key }@</b>
{% if value.get('required', False) %}<br/><div style="font-size: small; color: red">required</div>{% endif %} {% if value.get('required', False) %}<br/><div style="font-size: small; color: red">required</div>{% endif %}
{% if value.version_added %}<br/><div style="font-size: small; color: darkgreen">(added in @{value.version_added}@)</div>{% endif %} {% if value.version_added %}<br/><div style="font-size: small; color: darkgreen">(added in @{value.version_added}@)</div>{% endif %}
</div> </div>
<div class="outer-elbow-container"> </div>
</td> </td>
{# default value #} {# default / choices #}
<td><div class="cell-border">{% if value.default %}@{ value.default | html_ify }@{% endif %}</div></td>
{# choices #}
<td> <td>
<div class="cell-border"> <div class="cell-border">
{% if value.default is defined %}
{% if value.default == true %}
{% set _x = value.update({'default': 'yes'}) %}
{% elif value.default == false %}
{% set _x = value.update({'default': 'no'}) %}
{% endif %}
{% endif %}
{% if value.type == 'bool' %} {% if value.type == 'bool' %}
<ul> {% set _x = value.update({'choices': ['no', 'yes']}) %}
<li>yes</li> {% endif %}
<li>no</li>
</ul>
{% else %}
{% if value.choices %} {% if value.choices %}
<ul> <ul style="list-style-type: circle"><b>Choices:</b>
{% if value.default not in value.choices %}
<li type="disc"><div style="color: blue"><b>@{ value.default }@</b>&nbsp;&larr;</div></li>
{% endif %}
{% for choice in value.choices %} {% for choice in value.choices %}
{% if value.default is defined and choice == value.default %}
<li type="disc"><div style="color: blue"><b>@{ value.default }@</b>&nbsp;&larr;</div></li>
{% else %}
<li>@{ choice }@</li> <li>@{ choice }@</li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% elif value.default is defined %}
<div style="color: blue">@{ value.default | html_ify }@</div>
{% endif %} {% endif %}
</div> </div>
</td> </td>
@ -162,7 +170,7 @@ Options
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if 'aliases' in value and value.aliases %} {% if 'aliases' in value and value.aliases %}
</br><div style="font-size: small;">aliases: @{ value.aliases|join(', ') }@</div> <div style="font-size: small; color: darkgreen"><br/>aliases: @{ value.aliases|join(', ') }@</div>
{% endif %} {% endif %}
</div> </div>
</td> </td>
@ -176,7 +184,7 @@ Options
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</table> </table>
</br> <br/>
{% endif %} {% endif %}

Loading…
Cancel
Save