
{% macro render_nested_sections(options_dict, var_path, depth, parent_var_name) -%}
{% if options_dict %}
{% for option_name, option_spec in options_dict.items() %}
{% set underline_char = "~~~" if depth == 1 else "^^^" if depth == 2 else '"""' %}
{% set anchor_id = var_path + "-sub-" + option_name %}
{% set display_name = parent_var_name + "['" + option_name + "']" %}
``{{ display_name }}``
{{ underline_char * (display_name | length + 4) }}

`⇑ Back to ToC  ⇑ <#top>`_

{{ option_spec.description | format_description }}

:Type: ``{{ option_spec.type }}``
:Required: {{ 'Yes' if option_spec.required else 'No' }}
{% if option_spec.default is not none %}
:Default: {{ option_spec.default | format_default }}
{% endif %}
{% if option_spec.choices %}
:Choices: {{ option_spec.choices | map('string') | map('code_escape') | join(', ') }}
{% endif %}
{% if option_spec.elements %}
:List Elements: ``{{ option_spec.elements }}``
{% endif %}

{% if depth < 3 and option_spec.options %}
{{ render_nested_sections(option_spec.options, anchor_id, depth + 1, display_name) }}
{% elif depth >= 3 and option_spec.options %}
.. note::
   This option has more options but this README shows nested options up to level 3. Please refer to the argument_specs file for complete details.

{% endif %}
{% endfor %}
{% endif %}
{%- endmacro %}

Role variables
==============

{% if has_options %}
The following variables can be configured for this role:

.. csv-table::
   :header: "Variable", "Type", "Required", "Default", "Description (abstract)"
   :widths: 20, 10, 10, 15, 45

{% for var_name, var_spec in options.items() %}
   "``{{ var_name | ansible_escape }}``", "``{{ var_spec.type }}``", "{{ 'Yes' if var_spec.required else 'No' }}", "{{ var_spec.default | format_default | csv_escape }}", "{{ var_spec.description | format_table_description(var_name) | csv_escape }}"
{% endfor %}


{% for var_name, var_spec in options.items() %}
``{{ var_name }}``
{{ '-' * (var_name | length + 4) }}

`⇑ Back to ToC  ⇑ <#top>`_

{{ var_spec.description | format_description }}

:Type: ``{{ var_spec.type }}``
:Required: {{ 'Yes' if var_spec.required else 'No' }}
{% if var_spec.default is not none %}
:Default: {{ var_spec.default | format_default }}
{% endif %}
{% if var_spec.choices %}
:Choices: {{ var_spec.choices | map('string') | map('code_escape') | join(', ') }}
{% endif %}
{% if var_spec.elements %}
:List Elements: ``{{ var_spec.elements }}``
{% endif %}

{{ render_nested_sections(var_spec.options, "variable-" + var_name, 1, var_name) }}

{% endfor %}
{% else %}
No variables are defined for this role.
{% endif %}
