.. redirect-from::
Contributing/Contributing-To-ROS-2-Documentation
Contributing to ROS 2 Documentation
===================================
.. contents:: Table of Contents
:depth: 2
:local:
Contributions to this site are most welcome.
This page explains how to contribute to ROS 2 Documentation.
Please be sure to read the below sections carefully before contributing.
The site is built using `Sphinx `_, and more particularly using `Sphinx multiversion `_.
Branch structure
----------------
The source code of documentation is located in the `ROS 2 Documentation GitHub repository `_.
This repository is set up with one branch per ROS 2 distribution to handle differences between the distributions.
If a change is common to all ROS 2 distributions, it should be made to the ``rolling`` branch (and then will be backported as appropriate).
If a change is specific to a particular ROS 2 distribution, it should be made to the respective branch.
Source structure
----------------
The source files for the site are all located under the ``source`` subdirectory.
Templates for various sphinx plugins are located under ``source/_templates``.
The root directory contains configuration and files required to locally build the site for testing.
Building the site locally
-------------------------
Start by creating `venv `__ to build the documentation:
.. code-block:: console
# activate the venv
python3 -m venv ros2doc
# activate venv
source ros2doc/bin/activate
And install requirements located in the ``requirements.txt`` file:
.. tabs::
.. group-tab:: Linux
.. code-block:: console
pip install -r requirements.txt -c constraints.txt
.. group-tab:: macOS
.. code-block:: console
pip install -r requirements.txt -c constraints.txt
.. group-tab:: Windows
.. code-block:: console
python -m pip install -r requirements.txt -c constraints.txt
In order for Sphinx to be able to generate diagrams, the ``dot`` command must be available.
.. tabs::
.. group-tab:: Linux
.. code-block:: console
sudo apt update ; sudo apt install graphviz
.. group-tab:: macOS
.. code-block:: console
brew install graphviz
.. group-tab:: Windows
Download an installer from `the Graphviz Download page `__ and install it.
Make sure to allow the installer to add it to the Windows ``%PATH%``, otherwise Sphinx will not be able to find it.
Building the site for one branch
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To build the site for just this branch, type ``make html`` at the top-level of the repository.
This is the recommended way to test out local changes.
.. code-block:: console
make html
The build process can take some time.
To see the output, open ``build/html/index.html`` in your browser.
You can also run the documentation tests locally (using `doc8 `_) with the following command:
.. code-block:: console
make test
View Site Through Github CI
^^^^^^^^^^^^^^^^^^^^^^^^^^^
For small changes to the ROS 2 Docs you can view your changes as rendered HTML using artifacts generated in our Github Actions.
The "build" action produces the entire ROS Docs as a downloadable Zip file that contains all HTML for `docs.ros.org `_
This build action is triggered after passing the test action and lint action.
To download and view your changes first go to your pull request and under the title click the "Checks" tab.
On the left hand side of the checks page, click on the "Test" section under the "tests" section click on "build" dialog.
This will open a menu on the right, where you can click on "Upload document artifacts" and scroll to the bottom to see the download link for the Zipped' HTML files under the heading "Artifact download URL".
.. image:: ./images/github_action.png
:width: 100%
:alt: Steps to find rendered HTML files on ROS Github action
Building the site for all branches
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To build the site for all branches, type ``make multiversion`` from the ``rolling`` branch.
This has two drawbacks:
#. The multiversion plugin doesn't understand how to do incremental builds, so it always rebuilds everything.
This can be slow.
#. When typing ``make multiversion``, it will always check out exactly the branches listed in the ``conf.py`` file.
That means that local changes will not be shown.
To show local changes in the multiversion output, you must first commit the changes to a local branch.
Then you must edit the `conf.py `_ file and change the ``smv_branch_whitelist`` variable to point to your branch.
Checking for broken links
^^^^^^^^^^^^^^^^^^^^^^^^^
To check for broken links on the site, run:
.. code-block:: console
make linkcheck
This will check the entire site for broken links, and output the results to the screen and ``build/linkcheck``.
Migrating Pages from the ROS Wiki
---------------------------------
The first step in migrating a page from the `ROS Wiki `_ to the ROS 2 documentation is to determine if the page needs to be migrated.
Check if the content, or something similar, is available on https://docs.ros.org/en/{DISTRO} by searching for related terms.
If it has already been migrated, congratulations!
You are done.
If it hasn't been migrated, then consider whether it is worth keeping.
Pages that you or others find useful, and refer to regularly, are good candidates assuming they have not been superseded by other documentation.
Pages for ROS projects and features that are no longer supported by a current distribution should not be migrated.
The next step for migrating a ROS Wiki page is to determine the correct location for the migrated page.
Only ROS Wiki pages that cover core ROS concepts belong in the ROS Documentation, these pages should be migrated to a logical location within the ROS documentation.
Package specific documentation should be migrated to the package-level documentation generated in the package's source repository.
Once the package level documentation has been updated it will be visible `as part of the package-level documentation `__.
If you are unsure whether and where to migrate a page, please get in touch via an issue on https://github.com/ros2/ros2_documentation or on https://discourse.ros.org.
Once you've determined that a ROS Wiki page is worth migrating, and found an appropriate landing spot in the ROS documentation, the next step in the migration process is to set up the conversion tools necessary to migrate the page.
In most cases the only tools necessary to migrate a single ROS Wiki page to the ROS Docs are the `PanDoc `_ command line tool and a text editor.
PanDoc is supported by most modern operating systems using the installation instruction found on their website.
It is worth noting that the ROS Wiki uses an older wiki technology (MoinMoin), so the markup language used is an obscure dialect of the `MediaWiki `__ format.
We've found that the easiest way to migrate a page from the ROS Wiki is to convert it from HTML into reStructured text using PanDoc.
Migrating a Wiki File
^^^^^^^^^^^^^^^^^^^^^
#. Clone the appropriate repository. If you are migrating a page to the official documentation hosted here, then you should clone https://github.com/ros2/ros2_documentation.
#. Create a new Github branch for your migrated page. We suggest something like ``pagename-migration``.
#. Download the appropriate ROS Wiki page to an html file using wget or a similar tool (e.g. ``wget -O urdf.html https://wiki.ros.org/urdf``).
Alternatively you can use your web browser to save the page's HTML.
#. Next you need to remove the extraneous HTML in the file you downloaded
Using your browser's developer mode, find the name of the first useful HTML element in the Wiki page.
In most cases all of the HTML between the third line of the file, starting with the ```` tag, through the start of the first ```` tag can be safely removed.
In the case where there is a table of contents, the first useful tag may be an ```` tag. Similarly, the ROS wiki contains some footer text that starts with ``
`` and ends just above ``