Improve module docs return values (#36943)

* Improve module docs return values

Currently the 5 columns shown doesn't make optimal use of the screen
estate, especially for facts modules this is a problem.

* Add returned facts as a separate section

* Remove whitespace and add support section

Since Notes were moved higher up, the Author, Status and Maintainer
information was now placed under the Return Values section.

* Switch Last Updated and Copyright
pull/4420/head
Dag Wieers 2018-03-06 11:46:19 +01:00 committed by John R Barker
parent 7a4e270ae0
commit eb52a88fb6
2 changed files with 139 additions and 73 deletions

View File

@ -22,9 +22,7 @@
</script> </script>
<p> <p>
{%- if last_updated %}{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}<br/>{% endif %}
Copyright © 2018 Red Hat, Inc. <br/> Copyright © 2018 Red Hat, Inc. <br/>
{%- if last_updated %}
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
{%- endif %}
</p> </p>
</footer> </footer>

View File

@ -13,11 +13,8 @@
{% if version_added is defined and version_added != '' -%} {% if version_added is defined and version_added != '' -%}
.. versionadded:: @{ version_added | default('') }@ .. versionadded:: @{ version_added | default('') }@
{% endif %} {% endif %}
.. contents:: .. contents::
:local: :local:
:depth: 2 :depth: 2
@ -33,7 +30,6 @@
DEPRECATED DEPRECATED
---------- ----------
{# use unknown here? skip the fields? #} {# use unknown here? skip the fields? #}
:Removed in Ansible: version: @{ deprecated['removed_in'] | default('') | string | convert_symbols_to_format }@ :Removed in Ansible: version: @{ deprecated['removed_in'] | default('') | string | convert_symbols_to_format }@
:Why: @{ deprecated['why'] | default('') | convert_symbols_to_format }@ :Why: @{ deprecated['why'] | default('') | convert_symbols_to_format }@
@ -44,43 +40,40 @@ DEPRECATED
Synopsis Synopsis
-------- --------
{% if description -%}
{% if description %}
{% if description is string -%} {% if description is string -%}
* @{ description | convert_symbols_to_format }@ - @{ description | convert_symbols_to_format }@
{% else %} {% else %}
{% for desc in description -%} {% for desc in description %}
* @{ desc | convert_symbols_to_format }@ - @{ desc | convert_symbols_to_format }@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if aliases is defined -%} {% if aliases is defined -%}
Aliases: @{ ','.join(aliases) }@ Aliases: @{ ','.join(aliases) }@
{% endif %} {% endif %}
{% if requirements %} {% if requirements -%}
{% set req_title = 'Requirements' %}
Requirements
~~~~~~~~~~~~
{% if plugin_type == 'module' %} {% if plugin_type == 'module' %}
{% set req_title = req_title + ' (on host that executes module)' %} The below requirements are needed on the host that executes this @{ plugin_type }@.
{% else %}
The below requirements are needed on the local master node that executes this @{ plugin_type }@.
{% endif %} {% endif %}
@{ req_title }@
@{ '-' * req_title|length }@
{% for req in requirements %} {% for req in requirements %}
* @{ req | convert_symbols_to_format }@ - @{ req | convert_symbols_to_format }@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if options -%} {% if options -%}
Options Options
------- -------
@ -186,8 +179,8 @@ Options
</br> </br>
{% endif %} {% endif %}
{% if notes -%}
{% if notes -%}
Notes Notes
----- -----
@ -197,10 +190,9 @@ Notes
- @{ note | convert_symbols_to_format }@ - @{ note | convert_symbols_to_format }@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if examples or plainexamples -%}
{% if examples or plainexamples -%}
Examples Examples
-------- --------
@ -212,28 +204,29 @@ Examples
@{ example['code'] | escape | indent(4, True) }@ @{ example['code'] | escape | indent(4, True) }@
{% endfor %} {% endfor %}
{% if plainexamples %}@{ plainexamples | indent(4, True) }@{% endif %} {% if plainexamples %}@{ plainexamples | indent(4, True) }@{% endif %}
{% endif %} {% endif %}
{% if not returnfacts and returndocs and returndocs.ansible_facts is defined %}
{% set returnfacts = returndocs.ansible_facts.contains %}
{% set _x = returndocs.pop('ansible_facts', None) %}
{% endif %}
{% if returndocs -%} {% if returnfacts -%}
Returned Facts
Return Values --------------
------------- Facts returned by this module are added/updated in the ``hostvars`` host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.
Common return values are documented :ref:`here <common_return_values>`, the following are the fields unique to this @{ plugin_type }@:
.. raw:: html .. raw:: html
<table border=0 cellpadding=0 class="documentation-table"> <table border=0 cellpadding=0 class="documentation-table">
<tr> <tr>
<th class="head"><div class="cell-border">Name</div></th> <th class="head"><div class="cell-border">Fact</div></th>
<th class="head"><div class="cell-border">Description</div></th>
<th class="head"><div class="cell-border">Returned</div></th> <th class="head"><div class="cell-border">Returned</div></th>
<th class="head"><div class="cell-border">Type</div></th> <th class="head"><div class="cell-border">Description</div></th>
<th class="head"><div class="cell-border">Sample</div></th>
</tr> </tr>
{% for key, value in returndocs|dictsort recursive %} {% for key, value in returnfacts|dictsort recursive %}
<tr class="return-value-column"> <tr class="return-value-column">
<td> <td>
<div class="outer-elbow-container"> <div class="outer-elbow-container">
@ -243,21 +236,28 @@ Common return values are documented :ref:`here <common_return_values>`, the foll
{% endfor %} {% endfor %}
<div class="elbow-key"> <div class="elbow-key">
<b>@{ key }@</b> <b>@{ key }@</b>
<br/><div style="font-size: small; color: red">@{ value.type }@</div>
</div> </div>
</div> </div>
</td> </td>
<td>
{% if value.description is string %}
<div class="cell-border">@{ value.description | replace('\n', '\n ') | html_ify }@</div>
{% else %}
{% for desc in value.description %}
<div class="cell-border">@{ desc | replace('\n', '\n ') | html_ify }@</div>
{% endfor %}
{% endif %}
</td>
<td><div class="cell-border">@{ value.returned }@</div></td> <td><div class="cell-border">@{ value.returned }@</div></td>
<td><div class="cell-border">@{ value.type }@</div></td> <td>
<td><div class="cell-border">@{ value.sample | replace('\n', '\n ') | html_ify }@</div></td> <div class="cell-border">
{% if value.description is string %}
<div>@{ value.description | html_ify }@</div>
{% else %}
{% for desc in value.description %}
<div>@{ desc | html_ify }@</div>
{% endfor %}
{% endif %}
<br/>
{% if value.sample %}
<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> #}
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">@{ value.sample | html_ify }@</div>
{% endif %}
</div>
</td>
</tr> </tr>
{# --------------------------------------------------------- {# ---------------------------------------------------------
# sadly we cannot blindly iterate through the child dicts, # sadly we cannot blindly iterate through the child dicts,
@ -273,49 +273,117 @@ Common return values are documented :ref:`here <common_return_values>`, the foll
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</table> </table>
</br></br> <br/><br/>
{% endif %}
{% if author is defined -%}
Author
~~~~~~
{% for author_name in author %}
* @{ author_name }@
{% endfor %}
{% endif %} {% endif %}
{% if not deprecated %}
{% set support = { 'core': 'The Ansible Core Team', 'network': 'The Ansible Network Team', 'certified': 'an Ansible Partner', 'community': 'The Ansible Community', 'curated': 'A Third Party'} %}
{% set module_states = { 'preview': 'it is not guaranteed to have a backwards compatible interface', 'stableinterface': 'the maintainers for this module guarantee that no backward incompatible interface changes will be made'} %}
{% if metadata %}
{% if metadata.status %}
{% if returndocs -%}
Return Values
-------------
Common return values are documented :ref:`here <common_return_values>`, the following are the fields unique to this @{ plugin_type }@:
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th class="head"><div class="cell-border">Key</div></th>
<th class="head"><div class="cell-border">Returned</div></th>
<th class="head"><div class="cell-border">Description</div></th>
</tr>
{% for key, value in returndocs|dictsort recursive %}
<tr class="return-value-column">
<td>
<div class="outer-elbow-container">
{% for i in range(1, loop.depth) %}
<div class="elbow-placeholder">
</div>
{% endfor %}
<div class="elbow-key">
<b>@{ key }@</b>
<br/><div style="font-size: small; color: red">@{ value.type }@</div>
</div>
</div>
</td>
<td><div class="cell-border">@{ value.returned }@</div></td>
<td>
<div class="cell-border">
{% if value.description is string %}
<div>@{ value.description | html_ify }@</div>
{% else %}
{% for desc in value.description %}
<div>@{ desc | html_ify }@</div>
{% endfor %}
{% endif %}
<br/>
{% if value.sample %}
<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> #}
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">@{ value.sample | html_ify }@</div>
{% endif %}
</div>
</td>
</tr>
{# ---------------------------------------------------------
# sadly we cannot blindly iterate through the child dicts,
# since in some documentations,
# lists are used instead of dicts. This handles both types
# ---------------------------------------------------------#}
{% if value.contains %}
{% if value.contains.items %}
@{ loop(value.contains.items()) }@
{% elif value.contains[0].items %}
@{ loop(value.contains[0].items()) }@
{% endif %}
{% endif %}
{% endfor %}
</table>
<br/><br/>
{% endif %}
Status Status
~~~~~~ ------
{% if not deprecated %}
{% set support = { 'core': 'The Ansible Core Team', 'network': 'The Ansible Network Team', 'certified': 'an Ansible Partner', 'community': 'The Ansible Community', 'curated': 'A Third Party'} %}
{% set module_states = { 'preview': 'it is not guaranteed to have a backwards compatible interface', 'stableinterface': 'the maintainers for this module guarantee that no backward incompatible interface changes will be made'} %}
{% if metadata %}
{% if metadata.status %}
{% for cur_state in metadata.status %} {% for cur_state in metadata.status %}
This module is flagged as **@{cur_state}@** which means that @{module_states[cur_state]}@. This module is flagged as **@{cur_state}@** which means that @{module_states[cur_state]}@.
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if metadata.supported_by in ('core', 'network') %} {% if metadata.supported_by in ('core', 'network') %}
Support
Maintenance Info ~~~~~~~
~~~~~~~~~~~~~~~~
For more information about Red Hat's support of this @{ plugin_type }@, For more information about Red Hat's support of this @{ plugin_type }@,
please refer to this `Knowledge Base article <https://access.redhat.com/articles/rhel-top-support-policies/>`_ please refer to this `Knowledge Base article <https://access.redhat.com/articles/rhel-top-support-policies/>`_
{% endif %} {% endif %}
{% endif %} {% endif %}
{% else %}
This module is flagged as **deprecated** and will be removed in version { deprecated['removed_in'] | default('') | string | convert_symbols_to_format }@. For more information see :ref:`DEPRECATED`.
{% endif %} {% endif %}
If you notice any issues in this documentation you can `edit this document <https://github.com/ansible/ansible/edit/devel/lib/ansible/modules/@{ source }@?description=%3C!---%20Your%20description%20here%20--%3E%0A%0A+label:%20docsite_pr>`_ to improve it. {% if author is defined -%}
Author
~~~~~~
{% for author_name in author %}
- @{ author_name }@
{% endfor %}
{% endif %}
.. hint::
If you notice any issues in this documentation you can `edit this document <https://github.com/ansible/ansible/edit/devel/lib/ansible/modules/@{ source }@?description=%3C!---%20Your%20description%20here%20--%3E%0A%0A+label:%20docsite_pr>`_ to improve it.