Add basic docs on how to create a collection docsite with antsibull-docs. (#78387)

pull/78448/head
Felix Fontein 2 years ago committed by GitHub
parent ddd8b8bfd9
commit 733a767948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,6 +16,7 @@ You can create a collection and publish it to `Ansible Galaxy <https://galaxy.an
developing_collections_shared
developing_collections_testing
developing_collections_distributing
developing_collections_documenting
.. toctree::
:maxdepth: 2

@ -0,0 +1,30 @@
.. _documenting_collections:
***********************
Documenting collections
***********************
Documenting modules and plugins
===============================
Documenting modules is thoroughly documented in :ref:`module_documenting`. Plugins can be documented the same way as modules, that is with ``DOCUMENTATION``, ``EXAMPLES``, and ``RETURN`` blocks.
Documenting roles
=================
To document a role, you have to add a role argument spec by creating a file ``meta/argument_specs.yml`` in your role. See :ref:`role_argument_spec` for details. As an example, you can look at `the argument specs file <https://github.com/sensu/sensu-go-ansible/blob/master/roles/install/meta/argument_specs.yml>`_ of the :ref:`sensu.sensu_go.install role <ansible_collections.sensu.sensu_go.install_role>` on GitHub.
.. _build_collection_docsite:
Build a docsite with antsibull-docs
===================================
You can use `antsibull-docs <https://pypi.org/project/antsibull-docs>`_ to build a Sphinx-based docsite for your collection:
#. Create your collection and make sure you can use it with ansible-core by adding it to your :ref:`COLLECTIONS_PATHS`.
#. Create a directory ``dest`` and run ``antsibull-docs sphinx-init --use-current --dest-dir dest namespace.name``, where ``namespace.name`` is the name of your collection.
#. Go into ``dest`` and run ``pip -r requirements.txt``. You might want to create a venv and activate it first to avoid installing this globally.
#. Then run ``./build.sh``.
#. Open ``build/html/index.html`` in a browser of your choice.
If you want to add additional documentation to your collection next to the plugin, module, and role documentation, see :ref:`collections_doc_dir`.

@ -447,4 +447,4 @@ The use of "wildcard" imports such as ``from module_utils.basic import *`` is no
Testing module documentation
============================
To test Ansible documentation locally please :ref:`follow instruction<testing_module_documentation>`.
To test Ansible documentation locally please :ref:`follow instruction<testing_module_documentation>`. To test documentation in collections, please see :ref:`build_collection_docsite`.

@ -246,6 +246,8 @@ You can pass other keywords, including variables and tags, when importing roles:
When you add a tag to an ``import_role`` statement, Ansible applies the tag to `all` tasks within the role. See :ref:`tag_inheritance` for details.
.. _role_argument_spec:
Role argument validation
========================

Loading…
Cancel
Save