You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/docs/docsite/rst/dev_guide/style_guide/index.rst

220 lines
6.8 KiB
ReStructuredText

.. _style_guide:
*******************
Ansible style guide
*******************
Welcome to the Ansible style guide!
To create clear, concise, consistent, useful materials on docs.ansible.com, follow these guidelines:
.. contents::
:local:
Linguistic guidelines
=====================
We want the Ansible documentation to be:
* clear
* direct
* conversational
* easy to translate
We want reading the docs to feel like having an experienced, friendly colleague
explain how Ansible works.
Stylistic cheat-sheet
---------------------
This cheat-sheet illustrates a few rules that help achieve the "Ansible tone":
+-------------------------------+------------------------------+----------------------------------------+
| Rule | Good example | Bad example |
+===============================+==============================+========================================+
| Use active voice | You can run a task by | A task can be run by |
+-------------------------------+------------------------------+----------------------------------------+
| Use the present tense | This command creates a | This command will create a |
+-------------------------------+------------------------------+----------------------------------------+
| Address the reader | As you expand your inventory | When the number of managed nodes grows |
+-------------------------------+------------------------------+----------------------------------------+
| Use standard English | Return to this page | Hop back to this page |
+-------------------------------+------------------------------+----------------------------------------+
| Use American English | The color of the output | The colour of the output |
+-------------------------------+------------------------------+----------------------------------------+
Header case
-----------
Headers should be written in sentence case. For example, this section's title is
``Header case``, not ``Header Case`` or ``HEADER CASE``.
Backport/2.9/docs (#63247) * add more anchors to collections docs (#62827) (cherry picked from commit 7e01de96d741c6fb8a1ce04f92873ffb57c9b1b5) * add anchors to support galaxy links (#62808) (cherry picked from commit 1b3bf33bdf2530adb3a7cbf8055007acb09b3bb2) * doc: fix typos (#62852) (cherry picked from commit b33ae1494936cd04fa89bce51e6068829fc89a91) * Add some documentation about using plugins in collections (#62465) - FQCN requirements - Sharing code in collections - Limitations with inventory caching (cherry picked from commit d41050b28b2d3e8d4a97ce13344b04fc87f703a2) * Remove Latin phrases from the docs (#62419) * add styleguide about avoiding use of latin words (cherry picked from commit e7436e278f8945dd73b066c47280c1a17bc18ebe) * ovirt: Fixing typo in ovirt_disk examples (#62962) (cherry picked from commit 50dc41cca2e6d75a05e933c5286f41bde235b65f) * vmware guidlines: adjust the location of cloud-config-vcenter.ini.template (#62970) Update the location of the cloud-config-vcenter.ini.template template. The file has been moved by: 2e7d36a3f969b31570d7ee34e3f1f971c5c586a9. (cherry picked from commit 7ecfa4a471ae17ee15aa51f684bf7d340805d432) * Prefer https:// links in the docs site (#62939) This is a follow-up of last year's 1a11cec. It deals with links which at that point either were not present or did not support https://. (cherry picked from commit c8315bfd6097f680ae79de5e4d4ee23d0c1068c0) * fix minor typos (#62950) (cherry picked from commit ad580a71c475b570cdbd4c79aaf0082ecccdf5fc) * Modernize Vagrant documentation (#62923) * By requiring a slightly newer Vagrant version (from 2015) we get the same generated Ansible inventory format is still used by today's version of Vagrant. That extended inventory format also has the benefit of allowing for simpler Ansible examples. * Switching to a current and supported Ubuntu LTS version. (cherry picked from commit 0d79013f51ca67eddcb1a3f6ff0f4453b659ee81) * add ios/iosxr deprecated modules (#62908) (cherry picked from commit 6bbd9c9eca5992d9fc53dd8fd8814205afaf508d)
5 years ago
Avoid using Latin phrases
-------------------------
Latin words and phrases like ``e.g.`` or ``etc.``
are easily understood by English speakers.
They may be harder to understand for others and are also tricky for automated translation.
Use the following English terms in place of Latin terms or abbreviations:
Backport/2.9/docs (#64073) * clarify no subfolders and md only for collections /docs folder (#63808) (cherry picked from commit 6a2902c8d55f366bd577436effa2426b04ce65ee) * Fixed example error in windows_winrm user guide (#63922) The example code to configure TLS 1.2 Support using Ansible had an indention error. The register variable 'enable_tls12' was not indented. This caused the subsequent task to fail since the variable was not registered. (cherry picked from commit c562e17659abefce44a5e64fd798e6000b84a6f7) * Fix doc errors in AWS modules (#63851) * Fix register/debug in aws_batch_compute_environment * Fix aws_batch_job_queue doc errors * Fix module naming: `batch_job_queue` > `aws_batch_job_queue` * Fix missing register * Update debug task to use modern YAML format * Fix missing register + debug for lambda_policy * Fix YAML syntax for elb_application_lb_info module (cherry picked from commit e4f16368ed8060dd7a15a0078b4a21fb86d85baf) * Update documentation for package module (#63909) It is not clear from the documentation that list can be used (cherry picked from commit 7f2c367d78c1773e5e908e31196fd07a698db9ee) * [ec2_launch_template] Update description of state param (#63147) Currently, it is not possible to delete specific versions of an ec2 launch template. The module docs incorrectly suggest that there is a `version` param to the module that can be used to do that. This patch aims to correct that error. (cherry picked from commit 7ea72607534ce996c311c17ee4c6aaf83989ae9e) * template: Add a space in example block (#63930) (cherry picked from commit f279715c29530c9148616a5c3fa5af846586cb18) * revisions to docsite README (#63957) (cherry picked from commit 5c962ef859b37ac3a9707a3e1ac88f4b34b78038) * combine galaxy.com install roles details (#63486) (cherry picked from commit ee8a0882054b7f633cd8bc075ffc61b8eb136d4b) * Correct a typo (#64020) (cherry picked from commit 18f4f0549faabefbd0457cde0dd86b0d0fed406b) * Update password.py (#63965) Update the examples of the password lookup plugin to show how multiple options are joined together. (cherry picked from commit 92daec5d0bce5dfbb73fda52910de2a74d59fa7e) * Fix indentation of example (#63789) Remove no_log since module_defaults aren't displayed like set_fact was (cherry picked from commit 1e52782d6ba6e3e2c9d140ec47558c034f0d394f) * add newline to render table correctly (#63769) (cherry picked from commit 1aee11c86026e8493ce9acba30175fadcd6dc70f) * clarified some points on environment keyword usage (#64065) (cherry picked from commit 885ee62b53247bc0985bfb12a39149d7ab9d3f2d)
5 years ago
Backport/2.9/docs (#63247) * add more anchors to collections docs (#62827) (cherry picked from commit 7e01de96d741c6fb8a1ce04f92873ffb57c9b1b5) * add anchors to support galaxy links (#62808) (cherry picked from commit 1b3bf33bdf2530adb3a7cbf8055007acb09b3bb2) * doc: fix typos (#62852) (cherry picked from commit b33ae1494936cd04fa89bce51e6068829fc89a91) * Add some documentation about using plugins in collections (#62465) - FQCN requirements - Sharing code in collections - Limitations with inventory caching (cherry picked from commit d41050b28b2d3e8d4a97ce13344b04fc87f703a2) * Remove Latin phrases from the docs (#62419) * add styleguide about avoiding use of latin words (cherry picked from commit e7436e278f8945dd73b066c47280c1a17bc18ebe) * ovirt: Fixing typo in ovirt_disk examples (#62962) (cherry picked from commit 50dc41cca2e6d75a05e933c5286f41bde235b65f) * vmware guidlines: adjust the location of cloud-config-vcenter.ini.template (#62970) Update the location of the cloud-config-vcenter.ini.template template. The file has been moved by: 2e7d36a3f969b31570d7ee34e3f1f971c5c586a9. (cherry picked from commit 7ecfa4a471ae17ee15aa51f684bf7d340805d432) * Prefer https:// links in the docs site (#62939) This is a follow-up of last year's 1a11cec. It deals with links which at that point either were not present or did not support https://. (cherry picked from commit c8315bfd6097f680ae79de5e4d4ee23d0c1068c0) * fix minor typos (#62950) (cherry picked from commit ad580a71c475b570cdbd4c79aaf0082ecccdf5fc) * Modernize Vagrant documentation (#62923) * By requiring a slightly newer Vagrant version (from 2015) we get the same generated Ansible inventory format is still used by today's version of Vagrant. That extended inventory format also has the benefit of allowing for simpler Ansible examples. * Switching to a current and supported Ubuntu LTS version. (cherry picked from commit 0d79013f51ca67eddcb1a3f6ff0f4453b659ee81) * add ios/iosxr deprecated modules (#62908) (cherry picked from commit 6bbd9c9eca5992d9fc53dd8fd8814205afaf508d)
5 years ago
+-------------------------------+------------------------------+
| Latin | English |
+===============================+==============================+
| i.e | in other words |
+-------------------------------+------------------------------+
| e.g. | for example |
+-------------------------------+------------------------------+
| etc | and so on |
+-------------------------------+------------------------------+
| via | by/ through |
+-------------------------------+------------------------------+
| vs./versus | rather than/against |
+-------------------------------+------------------------------+
reStructuredText guidelines
===========================
The Ansible documentation is written in reStructuredText and processed by Sphinx.
We follow these technical or mechanical guidelines on all rST pages:
Header notation
---------------
Backport/2.9/docs (#63247) * add more anchors to collections docs (#62827) (cherry picked from commit 7e01de96d741c6fb8a1ce04f92873ffb57c9b1b5) * add anchors to support galaxy links (#62808) (cherry picked from commit 1b3bf33bdf2530adb3a7cbf8055007acb09b3bb2) * doc: fix typos (#62852) (cherry picked from commit b33ae1494936cd04fa89bce51e6068829fc89a91) * Add some documentation about using plugins in collections (#62465) - FQCN requirements - Sharing code in collections - Limitations with inventory caching (cherry picked from commit d41050b28b2d3e8d4a97ce13344b04fc87f703a2) * Remove Latin phrases from the docs (#62419) * add styleguide about avoiding use of latin words (cherry picked from commit e7436e278f8945dd73b066c47280c1a17bc18ebe) * ovirt: Fixing typo in ovirt_disk examples (#62962) (cherry picked from commit 50dc41cca2e6d75a05e933c5286f41bde235b65f) * vmware guidlines: adjust the location of cloud-config-vcenter.ini.template (#62970) Update the location of the cloud-config-vcenter.ini.template template. The file has been moved by: 2e7d36a3f969b31570d7ee34e3f1f971c5c586a9. (cherry picked from commit 7ecfa4a471ae17ee15aa51f684bf7d340805d432) * Prefer https:// links in the docs site (#62939) This is a follow-up of last year's 1a11cec. It deals with links which at that point either were not present or did not support https://. (cherry picked from commit c8315bfd6097f680ae79de5e4d4ee23d0c1068c0) * fix minor typos (#62950) (cherry picked from commit ad580a71c475b570cdbd4c79aaf0082ecccdf5fc) * Modernize Vagrant documentation (#62923) * By requiring a slightly newer Vagrant version (from 2015) we get the same generated Ansible inventory format is still used by today's version of Vagrant. That extended inventory format also has the benefit of allowing for simpler Ansible examples. * Switching to a current and supported Ubuntu LTS version. (cherry picked from commit 0d79013f51ca67eddcb1a3f6ff0f4453b659ee81) * add ios/iosxr deprecated modules (#62908) (cherry picked from commit 6bbd9c9eca5992d9fc53dd8fd8814205afaf508d)
5 years ago
`Section headers in reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections>`_
can use a variety of notations.
Sphinx will 'learn on the fly' when creating a hierarchy of headers.
To make our documents easy to read and to edit, we follow a standard set of header notations.
We use:
* ``###`` with overline, for parts:
.. code-block:: rst
###############
Developer guide
###############
* ``***`` with overline, for chapters:
.. code-block:: rst
*******************
Ansible style guide
*******************
* ``===`` for sections:
.. code-block:: rst
Mechanical guidelines
=====================
* ``---`` for subsections:
.. code-block:: rst
Internal navigation
-------------------
* ``^^^`` for sub-subsections:
.. code-block:: rst
Adding anchors
^^^^^^^^^^^^^^
* ``"""`` for paragraphs:
.. code-block:: rst
Paragraph that needs a title
""""""""""""""""""""""""""""
Internal navigation
-------------------
Backport/2.9/docs (#63247) * add more anchors to collections docs (#62827) (cherry picked from commit 7e01de96d741c6fb8a1ce04f92873ffb57c9b1b5) * add anchors to support galaxy links (#62808) (cherry picked from commit 1b3bf33bdf2530adb3a7cbf8055007acb09b3bb2) * doc: fix typos (#62852) (cherry picked from commit b33ae1494936cd04fa89bce51e6068829fc89a91) * Add some documentation about using plugins in collections (#62465) - FQCN requirements - Sharing code in collections - Limitations with inventory caching (cherry picked from commit d41050b28b2d3e8d4a97ce13344b04fc87f703a2) * Remove Latin phrases from the docs (#62419) * add styleguide about avoiding use of latin words (cherry picked from commit e7436e278f8945dd73b066c47280c1a17bc18ebe) * ovirt: Fixing typo in ovirt_disk examples (#62962) (cherry picked from commit 50dc41cca2e6d75a05e933c5286f41bde235b65f) * vmware guidlines: adjust the location of cloud-config-vcenter.ini.template (#62970) Update the location of the cloud-config-vcenter.ini.template template. The file has been moved by: 2e7d36a3f969b31570d7ee34e3f1f971c5c586a9. (cherry picked from commit 7ecfa4a471ae17ee15aa51f684bf7d340805d432) * Prefer https:// links in the docs site (#62939) This is a follow-up of last year's 1a11cec. It deals with links which at that point either were not present or did not support https://. (cherry picked from commit c8315bfd6097f680ae79de5e4d4ee23d0c1068c0) * fix minor typos (#62950) (cherry picked from commit ad580a71c475b570cdbd4c79aaf0082ecccdf5fc) * Modernize Vagrant documentation (#62923) * By requiring a slightly newer Vagrant version (from 2015) we get the same generated Ansible inventory format is still used by today's version of Vagrant. That extended inventory format also has the benefit of allowing for simpler Ansible examples. * Switching to a current and supported Ubuntu LTS version. (cherry picked from commit 0d79013f51ca67eddcb1a3f6ff0f4453b659ee81) * add ios/iosxr deprecated modules (#62908) (cherry picked from commit 6bbd9c9eca5992d9fc53dd8fd8814205afaf508d)
5 years ago
`Anchors (also called labels) and links <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#ref-role>`_
work together to help users find related content.
Local tables of contents also help users navigate quickly to the information they need.
All internal links should use the ``:ref:`` syntax.
Every page should have at least one anchor to support internal ``:ref:`` links.
Long pages, or pages with multiple levels of headers, can also include a local TOC.
Adding anchors
^^^^^^^^^^^^^^
* Include at least one anchor on every page
* Place the main anchor above the main header
* If the file has a unique title, use that for the main page anchor::
.. _unique_page::
* You may also add anchors elsewhere on the page
Adding internal links
^^^^^^^^^^^^^^^^^^^^^
* All internal links must use ``:ref:`` syntax. These links both point to the anchor defined above:
.. code-block:: rst
:ref:`unique_page`
:ref:`this page <unique_page>`
The second example adds custom text for the link.
Adding links to modules and plugins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Module links use the module name followed by ``_module`` for the anchor.
* Plugin links use the plugin name followed by the plugin type. For example, :ref:`enable become plugin <enable_become>`).
.. code-block:: rst
:ref:`this module <this_module>``
:ref:`that connection plugin <that_connection>`
Adding local TOCs
^^^^^^^^^^^^^^^^^
The page you're reading includes a `local TOC <http://docutils.sourceforge.net/docs/ref/rst/directives.html#table-of-contents>`_.
If you include a local TOC:
* place it below, not above, the main heading and (optionally) introductory text
* use the ``:local:`` directive so the page's main header is not included
* do not include a title
The syntax is:
.. code-block:: rst
.. contents::
:local:
More resources
==============
These pages offer more help with grammatical, stylistic, and technical rules for documentation.
.. toctree::
:maxdepth: 1
basic_rules
voice_style
trademarks
grammar_punctuation
spelling_word_choice
resources
.. seealso::
:ref:`community_documentation_contributions`
How to contribute to the Ansible documentation
:ref:`testing_documentation_locally`
How to build the Ansible documentation
`irc.freenode.net <http://irc.freenode.net>`_
#ansible-docs IRC chat channel