1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Various module doc fixes (#37256)

This PR includes:
- A fix for multiple-choice defaults
- A fix for messed up dictionary samples
- Cleaner defaults when they don't appear part of choices
This commit is contained in:
Dag Wieers 2018-03-12 21:50:52 +01:00 committed by scottb
parent b945846814
commit 80ba7b7402
3 changed files with 74 additions and 68 deletions

View file

@ -107,6 +107,7 @@ Parameters
{# default / choices #} {# default / choices #}
<td> <td>
<div class="cell-border"> <div class="cell-border">
{# Recalculate choices and boolean values #}
{% if value.default is defined %} {% if value.default is defined %}
{% if value.default == true %} {% if value.default == true %}
{% set _x = value.update({'default': 'yes'}) %} {% set _x = value.update({'default': 'yes'}) %}
@ -117,21 +118,21 @@ Parameters
{% if value.type == 'bool' %} {% if value.type == 'bool' %}
{% set _x = value.update({'choices': ['no', 'yes']}) %} {% set _x = value.update({'choices': ['no', 'yes']}) %}
{% endif %} {% endif %}
{# Show possible choices and highlight details #}
{% if value.choices %} {% if value.choices %}
<ul style="list-style-type: circle"><b>Choices:</b> <ul><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 %} {% if (value.default is string and choice == value.default) or (value.default is iterable and choice in value.default) %}
<li type="disc"><div style="color: blue"><b>@{ value.default }@</b>&nbsp;&larr;</div></li> <li type="disc"><div style="color: blue"><b>@{ choice | escape }@</b>&nbsp;&larr;</div></li>
{% else %} {% else %}
<li>@{ choice }@</li> <li type="circle">@{ choice | escape }@</li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% elif value.default is defined %} {% endif %}
<div style="color: blue">@{ value.default | html_ify }@</div> {# Show default value, when multiple choice or no choices #}
{% if value.default is defined and value.default not in value.choices %}
<b>Default:</b><br/><div style="color: blue">@{ value.default | escape }@</div>
{% endif %} {% endif %}
</div> </div>
</td> </td>
@ -239,8 +240,7 @@ Facts returned by this module are added/updated in the ``hostvars`` host facts a
<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>
@ -248,7 +248,7 @@ Facts returned by this module are added/updated in the ``hostvars`` host facts a
</div> </div>
</div> </div>
</td> </td>
<td><div class="cell-border">@{ value.returned }@</div></td> <td><div class="cell-border">@{ value.returned | html_ify }@</div></td>
<td> <td>
<div class="cell-border"> <div class="cell-border">
{% if value.description is string %} {% if value.description is string %}
@ -259,10 +259,10 @@ Facts returned by this module are added/updated in the ``hostvars`` host facts a
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<br/> <br/>
{% if value.sample %} {% if value.sample is defined and value.sample %}
<div style="font-size: smaller"><b>Sample:</b></div> <div style="font-size: smaller"><b>Sample:</b></div>
{# <div style="font-size: smaller; color: blue; word-wrap: break-word; overflow-wrap: break-word; word-break: break-all;">@{ value.sample | html_ify }@</div> #} {# TODO: The sample should be escaped, using | escape or | htmlify, but both mess things up beyond repair with dicts #}
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">@{ value.sample | html_ify }@</div> <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">@{ value.sample | replace('\n', '\n ') | html_ify }@</div>
{% endif %} {% endif %}
</div> </div>
</td> </td>
@ -313,7 +313,7 @@ Common return values are documented :ref:`here <common_return_values>`, the foll
</div> </div>
</div> </div>
</td> </td>
<td><div class="cell-border">@{ value.returned }@</div></td> <td><div class="cell-border">@{ value.returned | html_ify }@</div></td>
<td> <td>
<div class="cell-border"> <div class="cell-border">
{% if value.description is string %} {% if value.description is string %}
@ -324,10 +324,10 @@ Common return values are documented :ref:`here <common_return_values>`, the foll
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<br/> <br/>
{% if value.sample %} {% if value.sample is defined and value.sample %}
<div style="font-size: smaller"><b>Sample:</b></div> <div style="font-size: smaller"><b>Sample:</b></div>
{# <div style="font-size: smaller; color: blue; word-wrap: break-word; overflow-wrap: break-word; word-break: break-all;">@{ value.sample | html_ify }@</div> #} {# TODO: The sample should be escaped, using | escape or | htmlify, but both mess things up beyond repair with dicts #}
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">@{ value.sample | html_ify }@</div> <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">@{ value.sample | replace('\n', '\n ') | html_ify }@</div>
{% endif %} {% endif %}
</div> </div>
</td> </td>

View file

@ -49,22 +49,18 @@ EXAMPLES = '''
# Gather space usage about all imported ZFS pools # Gather space usage about all imported ZFS pools
- zpool_facts: properties='free,size' - zpool_facts: properties='free,size'
debug: msg='ZFS pool {{ item.name }} has {{ item.free }} free space out of {{ item.size }}.'
- debug: msg='ZFS pool {{ item.name }} has {{ item.free }} free space out of {{ item.size }}.'
with_items: '{{ ansible_zfs_pools }}' with_items: '{{ ansible_zfs_pools }}'
''' '''
RETURN = ''' RETURN = '''
name: ansible_facts:
description: ZFS pool name description: Dictionary containing all the detailed information about the ZFS pool facts
returned: always returned: always
type: string type: complex
sample: rpool contains:
parsable: ansible_zfs_pools:
description: if parsable output should be provided in machine friendly format.
returned: if 'parsable' is set to True
type: boolean
sample: True
zfs_pools:
description: ZFS pool facts description: ZFS pool facts
returned: always returned: always
type: string type: string
@ -110,6 +106,16 @@ zfs_pools:
"size": "49.8G", "size": "49.8G",
"version": "-" "version": "-"
} }
name:
description: ZFS pool name
returned: always
type: string
sample: rpool
parsable:
description: if parsable output should be provided in machine friendly format.
returned: if 'parsable' is set to True
type: boolean
sample: True
''' '''
from collections import defaultdict from collections import defaultdict

View file

@ -56,8 +56,8 @@ options:
C(ObjectInherit). C(ObjectInherit).
- For more information on the choices see MSDN InheritanceFlags enumeration - For more information on the choices see MSDN InheritanceFlags enumeration
at U(https://msdn.microsoft.com/en-us/library/system.security.accesscontrol.inheritanceflags.aspx). at U(https://msdn.microsoft.com/en-us/library/system.security.accesscontrol.inheritanceflags.aspx).
choices: [ ContainerInherit, None, ObjectInherit ] - Defaults to C(ContainerInherit, ObjectInherit) for Directories.
default: For Leaf File, 'None'; For Directory, 'ContainerInherit, ObjectInherit'; choices: [ ContainerInherit, ObjectInherit ]
propagation: propagation:
description: description:
- Propagation flag on the ACL rules. - Propagation flag on the ACL rules.