Skip to content

Commit d872032

Browse files
authored
Improvments to doc building with make (#587)
1 parent 3d91878 commit d872032

File tree

9 files changed

+49
-31
lines changed

9 files changed

+49
-31
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
name: build docs
2020
no_output_timeout: 25m
2121
command: |
22-
pip install .[doc]
23-
make
22+
pip install -r doc-requirements.txt
23+
make spec
2424
- store_artifacts:
2525
path: _site/
2626

.github/workflows/pages.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ jobs:
7676
# Install dependencies:
7777
- name: 'Install dependencies'
7878
run: |
79-
pip install .[doc]
79+
pip install -r doc-requirements.txt
8080
8181
# Generate the documentation:
8282
- name: 'Build documentation'
8383
run: |
8484
# Turn warnings into errors and ensure .doctrees is not deployed:
8585
export SPHINXOPTS="-b html -WT --keep-going -d doctrees"
86-
make
86+
make spec
8787
8888
# Configure Git:
8989
- name: 'Configure Git'

Makefile

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ SPHINXOPTS ?= -W --keep-going
33
SOURCEDIR = spec
44
BUILDDIR = _site
55

6-
.PHONY: default clean build
6+
.PHONY: default clean draft spec
77

8-
default: clean build
8+
default: clean spec
99

1010
clean:
11-
-rm -rf $(BUILDDIR)
12-
-find . -type d -name generated -exec rm -rf {} +
11+
rm -rf $(BUILDDIR)
12+
find . -type d -name generated -exec rm -rf {} +
1313

14-
build:
14+
draft:
15+
mkdir -p $(BUILDDIR)
16+
sphinx-build "$(SOURCEDIR)/draft" "$(BUILDDIR)/draft" $(SPHINXOPTS)
17+
18+
spec:
1519
mkdir -p $(BUILDDIR)
1620
cp "$(SOURCEDIR)/_ghpages/_gitignore.txt" "$(BUILDDIR)/.gitignore"
1721
cp "$(SOURCEDIR)/_ghpages/versions.json" "$(BUILDDIR)/versions.json"

README.md

+23-11
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,43 @@ this array API standard.
1818

1919
## Building docs locally
2020

21-
The spec website is comprised of multiple Sphinx docs (one for each spec version),
22-
all of which exist in `spec/` and rely on the modules found in `src/` (most
23-
notably `array_api_stubs`). To install these modules and the additional
24-
dependencies of the Sphinx docs, you can use
21+
### Quickstart
22+
23+
To install the local stubs and additional dependencies of the Sphinx docs, you
24+
can use `pip install -r doc-requirements.txt`. Then just running `make` at the
25+
root of the repository should build the whole spec website.
2526

2627
```sh
27-
$ pip install -e .[doc] # ensure you install the dependencies extra "doc"
28+
$ pip install -r doc-requirements.txt
29+
$ make
30+
$ ls _site/
31+
2021.12/ draft/ index.html latest/ versions.json
2832
```
2933

34+
### The nitty-gritty
35+
36+
The spec website is comprised of multiple Sphinx docs (one for each spec version),
37+
all of which exist in `spec/` and rely on the modules found in `src/` (most
38+
notably `array_api_stubs`). For purposes of building the docs, these `src/`
39+
modules do not need to be installed as they are added to the `sys.path` at
40+
runtime.
41+
3042
To build specific versions of the spec, run `sphinx-build` on the respective
3143
folder in `spec/`, e.g.
3244

3345
```sh
34-
$ sphinx-build spec/draft/ _site/draft/
46+
$ sphinx-build spec/2012.12/ _site/2012.12/
3547
```
3648

37-
To build the whole website, which includes every version of
38-
the spec, you can utilize the `make` commands defined in `spec/Makefile`; e.g.,
49+
Additionally, `make draft` aliases
3950

4051
```sh
41-
$ make
42-
$ ls _site/
43-
2021.12/ draft/ index.html latest/ versions.json
52+
$ sphinx-build spec/draft/ _site/draft/
4453
```
4554

55+
To build the whole website, which includes every version of the spec, you can
56+
utilize `make spec`.
57+
4658

4759
## Making a spec release
4860

doc-requirements.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sphinx==4.3.0
2+
sphinx-material==0.0.30
3+
myst-parser
4+
sphinx_markdown_tables
5+
sphinx_copybutton
6+
docutils<0.18
7+
sphinx-math-dollar

pyproject.toml

-11
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@ Source = "https://github.com/data-apis/array-api/"
1414
Documentation = "https://data-apis.org/array-api/"
1515
Homepage = "https://data-apis.org/"
1616

17-
[project.optional-dependencies]
18-
doc = [
19-
"sphinx==4.3.0",
20-
"sphinx-material==0.0.30",
21-
"myst-parser",
22-
"sphinx_markdown_tables",
23-
"sphinx_copybutton",
24-
"docutils<0.18",
25-
"sphinx-math-dollar",
26-
]
27-
2817
[build-system]
2918
requires = ["setuptools"]
3019
build-backend = "setuptools.build_meta"

spec/2021.12/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import sys
2+
from pathlib import Path
3+
sys.path.insert(0, str(Path(__file__).parents[2] / "src"))
24

35
from array_api_stubs import _2021_12 as stubs_mod
46
from _array_api_conf import *

spec/2022.12/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import sys
2+
from pathlib import Path
3+
sys.path.insert(0, str(Path(__file__).parents[2] / "src"))
24

35
from array_api_stubs import _2022_12 as stubs_mod
46
from _array_api_conf import *

spec/draft/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import sys
2+
from pathlib import Path
3+
sys.path.insert(0, str(Path(__file__).parents[2] / "src"))
24

35
from array_api_stubs import _draft as stubs_mod
46
from _array_api_conf import *

0 commit comments

Comments
 (0)