blob: 2b41867cb5c62aedfb8e363c101bd2469275115b [file] [log] [blame]
Zack Williams98fe2322021-09-20 15:02:11 -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
43license: $(VENV_NAME)
44 source $</bin/activate ; set -u ;\
45 reuse --version ;\
46 reuse --root . lint
47
48# clean up
49clean:
50 rm -rf $(BUILDDIR)
51
52clean-all: clean
53 rm -rf $(VENV_NAME)
54
55# build multiple versions
56multiversion: $(VENV_NAME) Makefile | prep $(OTHER_REPO_DOCS)
57 source $</bin/activate ; set -u ;\
58 sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
59 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
60
61# Catch-all target: route all unknown targets to Sphinx using the new
62# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
63%: $(VENV_NAME) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
64 source $</bin/activate ; set -u ;\
65 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)