Building the documentation#

The preferred way to build the ArviZ documentation when making changes to the website is doing so locally with sphinx. This how-to guide explains the steps to build the ArviZ docs locally.

If you are not familiar with Python or have issues installing sphinx, you can skip building the docs locally. Once you submit a pull request, a preview of the docs will be built by readthedocs. The Previewing doc changes section at the bottom of this page covers accessing this preview.

The reasons for the local build to be preferred over the readthedocs preview are:

  • Faster. The readthedocs preview needs to create and environment on which to install and run sphinx for every build. On your local machine, the environment is created once and reused.

  • Unlimited. Readthedocs has limits on the number of builds a project can request. If you push many commits in a short period of time (or there are people working on other PRs at the same time as you) this limit will be triggered, and readthedocs won’t generate any preview for a while.

  • Access to logs. While working on the documentation, it is common to run into issues and sphinx errors. If you build the documentation locally you will have access to all the logs and error messages generated by python and sphinx. On the other hand, we only have access to a subset of the logs from readthedocs, which can make troubleshooting harder.

If you are using Docker, see Building documentation with Docker.

Using sphinx locally#

ArviZ provides a Makefile to manage all doc building tasks.

Base workflow: make html#

To build the documentation you will need to execute make html on the command line.

Once the command finishes, you can use make preview to open the generated documentation on your browser.

Every time you make changes to the documentation you will need to run make html again. However, if you haven’t closed the documentation page that was open in the browser, you will be able to skip the make preview command.

Live preview workflow: make livehtml#

As calling make html every time you make changes can be annoying, it is also possible to install sphinx-autobuild with pip install sphinx-autobuild and then execute make livehtml on the command line. With that, the documentation will be rebuilt every time you save a doc related file.

Rebuild the docs from scratch: make cleandocs#

In some cases, nor make livehtml nor re-executing make html multiple times will serve to correctly update the documentation. This is common for example if working on conf.py or making changes to the API docs.

When that happens, you will need to run make cleandocs. This will clean all the cache and intermediate files so the next time you run make html or make livehtml the documentation will be built from scratch (which will therefore be slower than usual).

Previewing doc changes#

There is an easy way to check the preview of docs by opening a PR on GitHub. ArviZ uses readthedocs to automatically build the documentation. For previewing documentation changes, take the following steps:

  1. Go to the checks of your PR. Wait for the docs/readthedocs.org:arviz to complete.

    Note

    The green tick indicates that the given check has been built successfully.

  2. Click the Details button next to it.

  3. It will take you to the preview of ArviZ docs of your PR.

  4. Go to the webpage of the file you are working on.

  5. Check the preview of your changes on that page.

Note

Note The preview version of ArviZ docs will have a warning box that says “This page was created from a pull request (#Your PR number).” It shows the PR number whose changes have been implemented.

For example, a warning box will look like this:

Warning

This page was created from a pull request (#PR Number).