{% if not breadcrumbs %}
:orphan:
{% endif %}

{% macro list_plugins(plugin_type) %}
{%   for name, desc in plugin_maps[plugin_type].items() | sort %}
* :ref:`@{ name }@ @{ plugin_type }@ <ansible_collections.@{ collection_name }@.@{ name }@_@{ plugin_type }@>` -- @{ desc | rst_ify | indent(width=2) }@
{%   endfor %}
{% endmacro %}

.. _plugins_in_@{collection_name}@:

@{collection_name.title()}@
@{ '=' * (collection_name | length) }@

{% if collection_version %}
Collection version @{ collection_version }@
{% endif %}

.. contents::
   :local:
   :depth: 1

{% if collection_description or collection_authors or collection_links %}
Description
-----------

{%   if collection_description %}
@{ link_data.description | rst_ify }@
{%   endif %}

{%   if collection_authors %}
**Author@{ 's' if (collection_authors | length) > 1 else '' }@:**

{%     for author in collection_authors %}
* @{ author | indent(2) }@
{%     endfor %}
{%   endif %}

{%   if collection_links %}
.. raw:: html

  <p class="ansible-links">
{%     for link in collection_links %}
    <a href="@{ link.url | escape }@" aria-role="button" target="_blank" rel="noopener external">@{ link.description | escape }@</a>
{%     endfor %}
  </p>
{%   endif %}

{% endif %}

{% if not collection_communication.empty %}
.. Communication

.. _communication_for_@{collection_name}@:

Communication
-------------

{%   for matrix_room in collection_communication.matrix_rooms %}
- Matrix room :literal:`@{ matrix_room.room | rst_escape(escape_ending_whitespace=true) }@`: `@{ matrix_room.topic | rst_escape }@ <https://matrix.to/#/@{ matrix_room.room | rst_escape }@>`__.
{%   endfor %}
{%   for irc_channel in collection_communication.irc_channels %}
- IRC channel :literal:`@{ irc_channel.channel | rst_escape(escape_ending_whitespace=true) }@` (@{ irc_channel.network | rst_escape }@ network):
{%     if irc_channel.network == 'Libera' %}
  `@{ irc_channel.topic }@ <https://web.libera.chat/?channel=@{ irc_channel.channel | rst_escape }@>`__.
{%     else %}
  @{ irc_channel.topic | rst_escape }@.
{%     endif %}
{%   endfor %}
{%   for mailing_list in collection_communication.mailing_lists %}
- Mailing list: `@{ mailing_list.topic | rst_escape }@ <@{ mailing_list.url | rst_escape }@>`__.
{%     if mailing_list.subscribe %}
  (`Subscribe <mailto:@{ mailing_list.subscribe | rst_escape }@>`__)
{%     endif %}
{%   endfor %}
{% endif %}

.. toctree::
    :maxdepth: 1

{% for section in extra_docs_sections %}
@{section.title}@
@{ '-' * (section.title | length) }@

{%   if section.toctree %}
.. toctree::
    :maxdepth: 1

{%     for toctree_entry in section.toctree %}
    @{toctree_entry}@
{%     endfor %}
{%   endif %}

{% endfor %}

Plugin Index
------------

{% if plugin_maps | reject('eq', 'role') | list %}
These are the plugins in the @{collection_name}@ collection:
{% else %}
There are no plugins in the @{collection_name}@ collection with automatically generated documentation.
{% endif %}

{% for category in plugin_maps | reject('eq', 'role') | sort | move_first('module') %}

{%   if category == 'module' %}
Modules
~~~~~~~
{%   else %}
@{ category | capitalize }@ Plugins
@{ '~' * ((category | length) + 8) }@
{%   endif %}

@{   list_plugins(category) }@
{% endfor %}

{% if 'role' in plugin_maps %}
Role Index
----------

These are the roles in the @{collection_name}@ collection:

@{   list_plugins('role') }@
{% endif %}

.. seealso::

    List of :ref:`collections <list_of_collections>` with docs hosted here.

{% if breadcrumbs %}
.. toctree::
    :maxdepth: 1
    :hidden:

{%   for category, plugins in plugin_maps.items() | sort %}
{%     for name, desc in plugins.items() | sort %}
    @{ name }@_@{ category }@
{%     endfor %}
{%   endfor %}
{% endif %}
