blob: 4d57f91aaf7a26b17fad21a41ee020c3a6176f46 [file] [log] [blame]
Zack Williams553a3632019-08-09 17:14:43 -07001# Makefile for Trellis documentation created with Sphinx
2
3# use bash for pushd/popd, and to fail quickly. virtualenv's activate
4# has undefined variables, so no -u
5SHELL = bash -e -o pipefail
6
7# You can set these variables from the command line.
8SPHINXOPTS ?=
9SPHINXBUILD ?= sphinx-build
10SOURCEDIR ?= .
11BUILDDIR ?= _build
12
13# Put it first so that "make" without argument is like "make help".
14help: doc_venv
15 source ./doc_venv/bin/activate ;\
16 $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17
18.PHONY: help lint reload Makefile test
19
20# Create the virtualenv with all the tools installed
21doc_venv:
22 virtualenv doc_venv ;\
23 source ./doc_venv/bin/activate ;\
24 pip install livereload ;\
25 pip install -r requirements.txt
26
27# automatically reload changes in browser as they're made
28reload: doc_venv
29 source ./doc_venv/bin/activate ;\
30 set -u ;\
31 sphinx-reload $(SOURCEDIR)
32
33# lint and link verification. linkcheck is built into sphinx
34test: lint linkcheck
35
36lint: rst-lint
37
38rst-lint: doc_venv
39 source ./doc_venv/bin/activate ;\
40 set -u ;\
Charles Chan61dcfb62019-09-05 10:35:35 -070041 rstcheck -r $$(find . -name \*.rst ! -path "*doc_venv*")
Zack Williams553a3632019-08-09 17:14:43 -070042
43# clean up
44clean:
45 rm -rf $(BUILDDIR)
46
47clean-all: clean
48 rm -rf doc_venv
49
50# Catch-all target: route all unknown targets to Sphinx using the new
51# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
52%: Makefile doc_venv | $(OTHER_REPO_DOCS)
53 source ./doc_venv/bin/activate ;\
54 set -u ;\
55 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)