From 6636401246adfff277a1220c9a67964d99f07546 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Thu, 8 Mar 2018 19:48:15 +0100 Subject: [PATCH] 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 --- docs/templates/plugin.rst.j2 | 58 ++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/docs/templates/plugin.rst.j2 b/docs/templates/plugin.rst.j2 index 9dba81f95e7..1fe5507d267 100644 --- a/docs/templates/plugin.rst.j2 +++ b/docs/templates/plugin.rst.j2 @@ -74,8 +74,8 @@ The below requirements are needed on the local master node that executes this @{ {% if options -%} -Options -------- +Parameters +---------- .. raw:: html @@ -83,47 +83,55 @@ Options {# Header of the documentation #}
Parameter
-
Default
-
Choices
+
Choices/Defaults
{% if plugin_type != 'module' %}
Configuration
{% endif %} -
Comments
+
Comments
{% for key, value in options|dictsort recursive %} - {# parameter name with introduced label #} + {# parameter name with required and/or introduced label #}
{% for i in range(1, loop.depth) %} -
-
+
{% endfor %}
@{ key }@ {% if value.get('required', False) %}
required
{% endif %} {% if value.version_added %}
(added in @{value.version_added}@)
{% endif %}
-
+
- {# default value #} -
{% if value.default %}@{ value.default | html_ify }@{% endif %}
- {# choices #} + {# default / choices #}
+ {% 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' %} -
    -
  • yes
  • -
  • no
  • -
- {% else %} - {% if value.choices %} -
    - {% for choice in value.choices %} + {% set _x = value.update({'choices': ['no', 'yes']}) %} + {% endif %} + {% if value.choices %} +
      Choices: + {% if value.default not in value.choices %} +
    • @{ value.default }@ ←
    • + {% endif %} + {% for choice in value.choices %} + {% if value.default is defined and choice == value.default %} +
    • @{ value.default }@ ←
    • + {% else %}
    • @{ choice }@
    • - {% endfor %} -
    - {% endif %} + {% endif %} + {% endfor %} +
+ {% elif value.default is defined %} +
@{ value.default | html_ify }@
{% endif %}
@@ -162,7 +170,7 @@ Options {% endfor %} {% endif %} {% if 'aliases' in value and value.aliases %} -
aliases: @{ value.aliases|join(', ') }@
+

aliases: @{ value.aliases|join(', ') }@
{% endif %}
@@ -176,7 +184,7 @@ Options {% endif %} {% endfor %} -
+
{% endif %}