Skip to content

Commit

Permalink
Add docs build steps to README (#37) (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
oraNod authored Jul 10, 2023
1 parent d1d31a8 commit 4376b51
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ansible-documentation

This repository holds the ReStructuredText (RST) source, and other files, for user documentation related to the Ansible package and Ansible core.

> Documentation for modules and plugins that are officially supported by the Ansible core engineering team is available in the [`ansible/ansible`](https://github.com/ansible/ansible) repository.
## Building Ansible community documentation

Follow the documentation to [set up your environment](https://docs.ansible.com/ansible/latest/community/documentation_contributions.html#setting-up-your-environment-to-build-documentation-locally) and then [build Ansible community documentation locally](https://docs.ansible.com/ansible/latest/community/documentation_contributions.html#building-the-documentation-locally)
43 changes: 26 additions & 17 deletions docs/docsite/rst/community/documentation_contributions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To add a helpful review, please:
Opening a new issue and/or PR
=============================

If the problem you have noticed is too complex to fix with the ``Edit on GitHub`` option, and no open issue or PR already documents the problem, please open an issue and/or a PR on the correct underlying repo - ``ansible/ansible`` for most pages that are not plugin or module documentation. If the documentation page has no ``Edit on GitHub`` option, check if the page is for a module within a collection. If so, follow the link to the collection on Galaxy and select the ``repo`` button in the upper right corner to find the source repository for that collection and module. The Collection README file should contain information on how to contribute to that collection, or report issues.
If the problem you have noticed is too complex to fix with the ``Edit on GitHub`` option, and no open issue or PR already documents the problem, please open an issue and/or a PR on the correct underlying repo - ``ansible/ansible-documentation`` for most pages that are not plugin or module documentation. If the documentation page has no ``Edit on GitHub`` option, check if the page is for a module within a collection. If so, follow the link to the collection on Galaxy and select the ``repo`` button in the upper right corner to find the source repository for that collection and module. The Collection README file should contain information on how to contribute to that collection, or report issues.

A great documentation GitHub issue or PR includes:

Expand All @@ -73,25 +73,23 @@ A great documentation GitHub issue or PR includes:
Verifying your documentation PR
================================

If you make multiple changes to the documentation on ``ansible/ansible``, or add more than a line to it, before you open a pull request, please:
If you make multiple changes to the documentation, or add more than a line to it, before you open a pull request, please:

#. Check that your text follows our :ref:`style_guide`.
#. Test your changes for rST errors.
#. Build the page, and preferably the entire documentation site, locally.

.. note::

The following sections apply to documentation sourced from the ``ansible/ansible`` repo and does not apply to documentation from an individual collection. See the collection README file for details on how to contribute to that collection.
The following sections apply to documentation sourced from the ``ansible/ansible-documentation`` repo and does not apply to documentation from an individual collection. See the collection README file for details on how to contribute to that collection.

Setting up your environment to build documentation locally
----------------------------------------------------------

To build documentation locally, ensure you have a working :ref:`development environment <environment_setup>`.

To work with documentation on your local machine, you need to have python-3.9 or greater and install the `Ansible dependencies`_ and `documentation dependencies`_, which are listed in two files to make installation easier:

.. _Ansible dependencies: https://github.com/ansible/ansible/blob/devel/requirements.txt
.. _documentation dependencies: https://github.com/ansible/ansible/blob/devel/docs/docsite/requirements.txt
To work with documentation on your local machine, you should use a version of Python that meets the minimum requirement for ``ansible-core``.
For more information on minimum Python versions, see the :ref:`support matrix <support_life>`.

Drop the ``--user`` option in the following commands if you use a virtual environment (venv/virtenv).

Expand All @@ -101,18 +99,18 @@ Drop the ``--user`` option in the following commands if you use a virtual enviro
pip install --user --upgrade pip
#. Install Ansible dependencies.
#. Clone required parts of Ansible core for the docs build.

.. code-block:: bash
pip install --user -r requirements.txt
python3 docs/bin/clone-core.py
#. Install either the unpinned or tested documentation dependencies.

.. code-block:: bash
pip install --user -r docs/docsite/requirements.txt # This file installs unpinned versions that can cause problems with the Ansible docs build.
pip install --user -r test/sanity/code-smell/docs-build.requirements.txt # This file installs tested dependency versions that are used by CI.
pip install --user -r docs/docsite/requirements.txt # This file installs the unpinned dependency versions.
pip install --user -r tests/requirements.txt # This file installs tested dependency versions.
.. note::

Expand All @@ -127,7 +125,7 @@ Drop the ``--user`` option in the following commands if you use a virtual enviro

.. note::

After checking out ``ansible/ansible``, make sure the ``docs/docsite/rst`` directory has strict enough permissions. It should only be writable by the owner's account. If your default ``umask`` is not 022, you can use ``chmod go-w docs/docsite/rst`` to set the permissions correctly in your new branch. Optionally, you can set your ``umask`` to 022 to make all newly created files on your system (including those created by ``git clone``) have the correct permissions.
After checking out ``ansible/ansible-documentation``, make sure the ``docs/docsite/rst`` directory has strict enough permissions. It should only be writable by the owner's account. If your default ``umask`` is not 022, you can use ``chmod go-w docs/docsite/rst`` to set the permissions correctly in your new branch. Optionally, you can set your ``umask`` to 022 to make all newly created files on your system (including those created by ``git clone``) have the correct permissions.

.. _testing_documentation_locally:

Expand All @@ -143,13 +141,24 @@ To test an individual file for rST errors:
Building the documentation locally
----------------------------------

Building the documentation is the best way to check for errors and review your changes. Once `rstcheck` runs with no errors, navigate to ``ansible/docs/docsite`` and then build the page(s) you want to review.
Building the documentation is the best way to check for errors and review your changes. Once `rstcheck` runs with no errors, navigate to ``ansible-documentation/docs/docsite`` and then build the page(s) you want to review.

.. note::

If building on macOS with Python 3.8 or later, you must use Sphinx >= 2.2.2. See `#6803 <https://github.com/sphinx-doc/sphinx/pull/6879>`_ for details.


Periodically cloning Ansible core
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Documentation in the ``ansible/ansible-documentation`` repository builds "on top of" the ``ansible/ansible`` repository.
When you set up your local build environment, you clone the relevant parts Ansible core.

To ensure that you use the latest source from Ansible core, you should periodically run the following script before you build documentation:

.. code-block:: bash
python3 docs/bin/clone-core.py
Building a single rST page
^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -226,11 +235,11 @@ When you submit a documentation pull request, automated tests are run. Those sam

.. code-block:: bash
make clean &&
bin/ansible-test sanity --test docs-build &&
bin/ansible-test sanity --test rstcheck
make clean -C docs/docsite
python tests/sanity.py docs-build
python tests/sanity.py rstcheck
Unfortunately, leftover rST-files from previous document-generating can occasionally confuse these tests. It is therefore safest to run them on a clean copy of the repository, which is the purpose of ``make clean``. If you type these three lines one at a time and manually check the success of each, you do not need the ``&&``.
It is recommended to run tests on a clean copy of the repository, which is the purpose of the ``make clean`` command.

Joining the documentation working group
=======================================
Expand Down

0 comments on commit 4376b51

Please sign in to comment.