blob: 9f3cc5c00df8be4bb2c917373eba22805e368c9f [file] [log] [blame]
Zack Williamsccaa38a2021-11-16 15:36:05 -07001# Makefile for Sphinx documentation
2
3# use bash for pushd/popd, and to fail quickly
4SHELL = bash -e -o pipefail
5
6# You can set these variables from the command line.
7SPHINXOPTS ?= -W
8SPHINXBUILD ?= sphinx-build
9SOURCEDIR ?= .
10BUILDDIR ?= _build
11
12# name of python virtualenv that is used to run commands
13VENV_NAME := venv-docs
14
15.PHONY: help test lint doc8 reload Makefile prep
16
17# Put it first so that "make" without argument is like "make help".
18help: $(VENV_NAME)
19 source $</bin/activate ; set -u ;\
20 $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21
22# Create the virtualenv with all the tools installed
23$(VENV_NAME):
24 python3 -m venv $(VENV_NAME) ;\
25 source $@/bin/activate ;\
26 pip install -r requirements.txt
27
28# automatically reload changes in browser as they're made
29reload: $(VENV_NAME)
30 source $</bin/activate ; set -u ;\
31 sphinx-reload $(SOURCEDIR)
32
33# lint and link verification. linkcheck is part of sphinx
34test: lint spelling linkcheck
35
36lint: doc8
37
38doc8: $(VENV_NAME) | $(OTHER_REPO_DOCS)
39 source $</bin/activate ; set -u ;\
40 doc8 --max-line-length 119 \
41 $$(find . -name \*.rst ! -path "*venv*" ! -path "*vendor*" ! -path "*repos*" )
42
43# clean up
44clean:
45 rm -rf $(BUILDDIR)
46
47clean-all: clean
48 rm -rf $(VENV_NAME)
49
50# build multiple versions
51multiversion: $(VENV_NAME) Makefile | prep $(OTHER_REPO_DOCS)
52 source $</bin/activate ; set -u ;\
53 sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
54 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
55
56# Catch-all target: route all unknown targets to Sphinx using the new
57# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
58%: $(VENV_NAME) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
59 source $</bin/activate ; set -u ;\
60 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)