mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Docs: Add a "seealso" section to the module docs (#45949)
* Docs: Add a separate "seealso" section to the module docs
to list related modules and/or related references. This clears up the notes
section for things that are actual notes.
So you can add a section in your module documentation and four types of
references are possible.
seealso:
# Reference by module name
- module: aci_tenant
# Reference by module name, including description
- module: aci_tenant
description: ACI module to create tenants on a Cisco ACI fabric.
# Reference by rST documentation anchor
- ref: aci_guide
description: Detailed information on how to manage your ACI infrastructure using Ansible.
# Reference by Internet resource
- name: APIC Management Information Model reference
description: Complete reference of the APIC object model.
link: https://developer.cisco.com/docs/apic-mim-ref/
This PR also includes:
- Implements ansible-doc support
- Implements schema support for the seealso options
- Updates to the development documentation
- Rename filter convert_symbols_to_format to rst_ify, cfr the existing html_ify and tty_ify filters
- This makes the existing template a lot easier to read and fixes the confusion I had myself rereading the template (again).
- We fixed the possible suboption types (which was limited to 'bool' only)
* Use latest stable instead of devel docs
This commit is contained in:
committed by
Alicia Cozine
parent
6b09e99664
commit
baf0ad2309
@@ -207,6 +207,7 @@ def get_plugin_info(module_dir, limit_to=None, verbose=False):
|
||||
:aliases: set of aliases to this module name
|
||||
:metadata: The modules metadata (as recorded in the module)
|
||||
:doc: The documentation structure for the module
|
||||
:seealso: The list of dictionaries with references to related subjects
|
||||
:examples: The module's examples
|
||||
:returndocs: The module's returndocs
|
||||
|
||||
@@ -363,7 +364,7 @@ def jinja2_environment(template_dir, typ, plugin_type):
|
||||
|
||||
templates = {}
|
||||
if typ == 'rst':
|
||||
env.filters['convert_symbols_to_format'] = rst_ify
|
||||
env.filters['rst_ify'] = rst_ify
|
||||
env.filters['html_ify'] = html_ify
|
||||
env.filters['fmt'] = rst_fmt
|
||||
env.filters['xline'] = rst_xline
|
||||
|
||||
@@ -224,7 +224,34 @@ All fields in the ``DOCUMENTATION`` block are lower-case. All fields are require
|
||||
:notes:
|
||||
|
||||
* Details of any important information that doesn't fit in one of the above sections.
|
||||
* For example, whether ``check_mode`` is or is not supported, or links to external documentation.
|
||||
* For example, whether ``check_mode`` is or is not supported.
|
||||
|
||||
:seealso:
|
||||
|
||||
* A list of references to other modules, documentation or Internet resources
|
||||
* A reference can be one of the following formats:
|
||||
|
||||
|
||||
.. code-block:: yaml+jinja
|
||||
|
||||
seealso::
|
||||
|
||||
# Reference by module name
|
||||
- module: aci_tenant
|
||||
|
||||
# Reference by module name, including description
|
||||
- module: aci_tenant
|
||||
description: ACI module to create tenants on a Cisco ACI fabric.
|
||||
|
||||
# Reference by rST documentation anchor
|
||||
- ref: aci_guide
|
||||
description: Detailed information on how to manage your ACI infrastructure using Ansible.
|
||||
|
||||
# Reference by Internet resource
|
||||
- name: APIC Management Information Model reference
|
||||
description: Complete reference of the APIC object model.
|
||||
link: https://developer.cisco.com/docs/apic-mim-ref/
|
||||
|
||||
|
||||
Linking within module documentation
|
||||
-----------------------------------
|
||||
@@ -239,7 +266,8 @@ You can link from your module documentation to other module docs, other resource
|
||||
|
||||
.. note::
|
||||
|
||||
To refer a collection of modules, use ``C(..)``, e.g. ``Refer to the C(win_*) modules.``
|
||||
- To refer a collection of modules, use ``C(..)``, e.g. ``Refer to the C(win_*) modules.``
|
||||
- Because it stands out better, using ``seealso`` is preferred for general references over the use of notes or adding links to the description.
|
||||
|
||||
Documentation fragments
|
||||
-----------------------
|
||||
@@ -248,10 +276,13 @@ If you're writing multiple related modules, they may share common documentation,
|
||||
|
||||
For example, all AWS modules should include::
|
||||
|
||||
.. code-block:: yaml+jinja
|
||||
|
||||
extends_documentation_fragment:
|
||||
- aws
|
||||
- ec2
|
||||
|
||||
|
||||
You can find more examples by searching for ``extends_documentation_fragment`` under the Ansible source tree.
|
||||
|
||||
.. _examples_block:
|
||||
|
||||
43
docs/templates/plugin.rst.j2
vendored
43
docs/templates/plugin.rst.j2
vendored
@@ -11,7 +11,7 @@
|
||||
{% endfor %}
|
||||
|
||||
{% if short_description %}
|
||||
{% set title = module + ' - ' + short_description|convert_symbols_to_format %}
|
||||
{% set title = module + ' - ' + short_description | rst_ify %}
|
||||
{% else %}
|
||||
{% set title = module %}
|
||||
{% endif %}
|
||||
@@ -39,9 +39,9 @@
|
||||
DEPRECATED
|
||||
----------
|
||||
{# use unknown here? skip the fields? #}
|
||||
:Removed in Ansible: version: @{ deprecated['removed_in'] | default('') | string | convert_symbols_to_format }@
|
||||
:Why: @{ deprecated['why'] | default('') | convert_symbols_to_format }@
|
||||
:Alternative: @{ deprecated['alternative'] | default('')| convert_symbols_to_format }@
|
||||
:Removed in Ansible: version: @{ deprecated['removed_in'] | default('') | string | rst_ify }@
|
||||
:Why: @{ deprecated['why'] | default('') | rst_ify }@
|
||||
:Alternative: @{ deprecated['alternative'] | default('') | rst_ify }@
|
||||
|
||||
|
||||
{% endif %}
|
||||
@@ -51,10 +51,10 @@ Synopsis
|
||||
{% if description -%}
|
||||
|
||||
{% if description is string -%}
|
||||
- @{ description | convert_symbols_to_format }@
|
||||
- @{ description | rst_ify }@
|
||||
{% else %}
|
||||
{% for desc in description %}
|
||||
- @{ desc | convert_symbols_to_format }@
|
||||
- @{ desc | rst_ify }@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
@@ -75,7 +75,7 @@ The below requirements are needed on the local master node that executes this @{
|
||||
{% endif %}
|
||||
|
||||
{% for req in requirements %}
|
||||
- @{ req | convert_symbols_to_format }@
|
||||
- @{ req | rst_ify }@
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
@@ -206,17 +206,40 @@ Parameters
|
||||
{% endif %}
|
||||
|
||||
{% if notes -%}
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
.. note::
|
||||
{% for note in notes %}
|
||||
- @{ note | convert_symbols_to_format }@
|
||||
- @{ note | rst_ify }@
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if seealso -%}
|
||||
See Also
|
||||
--------
|
||||
|
||||
.. seealso::
|
||||
|
||||
{% for item in seealso %}
|
||||
{% if item.module is defined and item.description is defined %}
|
||||
:ref:`Module @{ item.module }@ <@{ item.module }@_module>`
|
||||
@{ item.description | rst_ify }@
|
||||
{% elif item.module is defined %}
|
||||
:ref:`@{ item.module }@_module`
|
||||
The official documentation on the **@{ item.module }@** module.
|
||||
{% elif item.name is defined and item.link is defined and item.description is defined %}
|
||||
`@{ item.name }@ <@{ item.link }@>`_
|
||||
@{ item.description | rst_ify }@
|
||||
{% elif item.ref is defined and item.description is defined %}
|
||||
:ref:`@{ item.ref }@`
|
||||
@{ item.description | rst_ify }@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if examples or plainexamples -%}
|
||||
|
||||
Examples
|
||||
@@ -421,7 +444,7 @@ please refer to this `Knowledge Base article <https://access.redhat.com/articles
|
||||
|
||||
{% else %}
|
||||
|
||||
This @{ plugin_type }@ is flagged as **deprecated** and will be removed in version @{ deprecated['removed_in'] | default('') | string | convert_symbols_to_format }@. For more information see `DEPRECATED`_.
|
||||
This @{ plugin_type }@ is flagged as **deprecated** and will be removed in version @{ deprecated['removed_in'] | default('') | string | rst_ify }@. For more information see `DEPRECATED`_.
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user