Skip to content

Commit fd27b97

Browse files
Docs infra (#2082)
* improve doc build process * pr tutorial cleanup * add subsections * add rtd preview link to PR description * Update doc/source/contributing/sphinx_doc_build.md Co-authored-by: Ravin Kumar <[email protected]> Co-authored-by: Ravin Kumar <[email protected]>
1 parent 8e3f731 commit fd27b97

File tree

7 files changed

+104
-48
lines changed

7 files changed

+104
-48
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Read the Docs Pull Request Preview
2+
on:
3+
pull_request_target:
4+
types:
5+
- opened
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
documentation-links:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: readthedocs/readthedocs-preview@main
15+
with:
16+
project-slug: "arviz"

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS = -b html
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = ArviZ
8+
SOURCEDIR = doc/source
9+
BUILDDIR = doc/build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
html:
18+
sphinx-build "$(SOURCEDIR)" "$(BUILDDIR)" -b html
19+
20+
livehtml:
21+
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" -b html
22+
23+
cleandocs:
24+
rm -r "$(BUILDDIR)" "doc/jupyter_execute" "$(SOURCEDIR)/api/generated" "$(SOURCEDIR)/examples" "$(SOURCEDIR)/example_thumbs"
25+
26+
preview:
27+
python -m webbrowser "$(BUILDDIR)/index.html"

doc/Makefile

Lines changed: 0 additions & 20 deletions
This file was deleted.

doc/source/contributing/pr_tutorial.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ clone it to your local machine, and develop on a feature branch.
1818
:sync: ssh
1919

2020
```
21-
$ git clone [email protected]:<your GitHub handle>/arviz.git
21+
git clone [email protected]:<your GitHub handle>/arviz.git
2222
```
2323
:::
2424

2525
:::{tab-item} HTTPS
2626
:sync: https
2727

2828
```
29-
$ git clone https://github.com/<your GitHub handle>/arviz.git
29+
git clone https://github.com/<your GitHub handle>/arviz.git
3030
```
3131
:::
3232

@@ -40,17 +40,17 @@ clone it to your local machine, and develop on a feature branch.
4040
:sync: ssh
4141

4242
```
43-
$ cd arviz
44-
$ git remote add upstream [email protected]:arviz-devs/arviz.git
43+
cd arviz
44+
git remote add upstream [email protected]:arviz-devs/arviz.git
4545
```
4646
:::
4747

4848
:::{tab-item} HTTPS
4949
:sync: https
5050

5151
```
52-
$ cd arviz
53-
$ git remote add upstream https://github.com/arviz-devs/arviz
52+
cd arviz
53+
git remote add upstream https://github.com/arviz-devs/arviz.git
5454
```
5555
:::
5656

@@ -60,7 +60,7 @@ clone it to your local machine, and develop on a feature branch.
6060
4. Create a ``feature`` branch to hold your development changes:
6161

6262
```bash
63-
$ git checkout -b my-feature
63+
git checkout -b my-feature
6464
```
6565

6666
```{warning}
@@ -71,31 +71,31 @@ clone it to your local machine, and develop on a feature branch.
7171
5. Project requirements are in ``requirements.txt``, and libraries used for development are in ``requirements-dev.txt``. To set up a development environment, you may (probably in a [virtual environment](https://docs.python-guide.org/dev/virtualenvs/)) run:
7272

7373
```bash
74-
$ pip install -r requirements.txt
75-
$ pip install -r requirements-dev.txt
76-
$ pip install -r requirements-docs.txt # to generate docs locally
74+
pip install -r requirements.txt
75+
pip install -r requirements-dev.txt
76+
pip install -r requirements-docs.txt # to generate docs locally
7777
```
7878

7979
Alternatively, for developing the project in [Docker](https://docs.docker.com/), there is a script to setup the Docker environment for development. See {ref}`developing_in_docker`.
8080

8181
6. Develop the feature on your feature branch. Add your changes using git commands, ``git add`` and then ``git commit``, like:
8282

8383
```bash
84-
$ git add modified_files
85-
$ git commit -m "commit message here"
84+
git add modified_files
85+
git commit -m "commit message here"
8686
```
8787

8888
to record your changes locally.
8989
After committing, it is a good idea to sync with the base repository in case there have been any changes:
9090
```bash
91-
$ git fetch upstream
92-
$ git rebase upstream/main
91+
git fetch upstream
92+
git rebase upstream/main
9393
```
9494

9595
Then push the changes to your GitHub account with:
9696

9797
```bash
98-
$ git push -u origin my-feature
98+
git push -u origin my-feature
9999
```
100100

101101
7. Go to the GitHub web page of your fork of the ArviZ repo. Click the 'Pull request' button to send your changes to the project's maintainers for review. This will send an email to the committers.

doc/source/contributing/sphinx_doc_build.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,56 @@
11
(sphinx_doc_build)=
22
# Building the documentation
33

4-
The preferred workflow for contributing to ArviZ is to fork
5-
the [GitHub repository](https://github.com/arviz-devs/arviz/),
6-
clone it to your local machine, and develop on a feature branch. For a detailed description of the recommended development process, see the step-by-step guide {ref}`here <pr_steps>`.
4+
The preferred way to build the ArviZ documentation when making changes to the website is doing
5+
so locally with sphinx. This how-to guide explains the steps to build the ArviZ docs locally.
6+
7+
If you are not familiar with Python or have issues installing sphinx, you can skip
8+
building the docs locally. Once you submit a pull request, a preview of the docs
9+
will be built by readthedocs. The {ref}`preview_change` section at the bottom of
10+
this page covers accessing this preview.
11+
12+
The reasons for the local build to be preferred over the readthedocs preview are:
13+
* **Faster**. The readthedocs preview needs to create and environment on which to install and run
14+
sphinx _for every build_. On your local machine, the environment is created once and reused.
15+
* **Unlimited**. Readthedocs has limits on the number of builds a project can request.
16+
If you push many commits in a short period of time (or there are people working on other PRs
17+
at the same time as you) this limit will be triggered, and readthedocs won't generate any
18+
preview for a while.
19+
* **Access to logs**. While working on the documentation, it is common to run into issues
20+
and sphinx errors. If you build the documentation locally you will have access to all
21+
the logs and error messages generated by python and sphinx. On the other hand, we only have
22+
access to a subset of the logs from readthedocs, which can make troubleshooting harder.
723

824
If you are using Docker, see {ref}`building_doc_with_docker`.
925

10-
## Pull request checks
26+
## Using sphinx locally
27+
ArviZ provides a `Makefile` to manage all doc building tasks.
28+
29+
### Base workflow: `make html`
30+
To build the documentation you will need to execute `make html` on the command line.
1131

12-
Every PR has a list of checks that check if your changes follow the rules being followed by ArviZ docs.
13-
You can check why a specific test is failing by clicking the `Details` next to it. It will take you to errors and warning page. This page shows the details of errors, for example in case of docstrings:
32+
Once the command finishes, you can use `make preview` to open the generated documentation
33+
on your browser.
1434

15-
`arviz/plots/pairplot.py:127:0: C0301: Line too long (142/100) (line-too-long)`.
35+
Every time you make changes to the documentation you will need to run `make html` again.
36+
However, if you haven't closed the documentation page that was open in the browser, you
37+
will be able to skip the `make preview` command.
1638

17-
It means line 127 of the file `pairplot.py` is too long.
18-
For running tests locally, see the {ref}`pr_checklist`.
39+
### Live preview workflow: `make livehtml`
40+
As calling `make html` every time you make changes can be annoying, it is also possible
41+
to install [sphinx-autobuild](https://github.com/executablebooks/sphinx-autobuild)
42+
with `pip install sphinx-autobuild` and then execute
43+
`make livehtml` on the command line. With that, the documentation will be rebuilt every
44+
time you save a doc related file.
1945

46+
### Rebuild the docs from scratch: `make cleandocs`
47+
In some cases, nor `make livehtml` nor re-executing `make html` multiple times will
48+
serve to correctly update the documentation. This is common for example if working
49+
on `conf.py` or making changes to the API docs.
50+
51+
When that happens, you will need to run `make cleandocs`. This will clean all the cache
52+
and intermediate files so the next time you run `make html` or `make livehtml`
53+
the documentation will be built from scratch (which will therefore be slower than usual).
2054

2155
(preview_change)=
2256
## Previewing doc changes
@@ -43,4 +77,4 @@ For example, a warning box will look like this:
4377

4478
```{warning}
4579
This page was created from a pull request (#PR Number).
46-
```
80+
```

examples/bokeh/bokeh_plot_violin_single_sided.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Single sided Violinplot
3-
==========
3+
=======================
44
55
_thumb: .2, .8
66
"""
@@ -18,6 +18,5 @@
1818
ax=p1,
1919
backend="bokeh",
2020
shade_kwargs={"color": "lightsalmon"},
21-
show=True,
2221
labeller=labeller,
2322
)

examples/matplotlib/mpl_plot_violin_single_sided.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Violin plot single sided
3-
===========
3+
========================
44
55
_thumb: .2, .8
66
_example_title: Single sided violin plot

0 commit comments

Comments
 (0)