blob: d1160daa80b38c0f30fe31507ca8a015236ad9a5 [file] [log] [blame]
# Makefile for Trellis documentation created with Sphinx
# use bash for pushd/popd, and to fail quickly. virtualenv's activate
# has undefined variables, so no -u
SHELL = bash -e -o pipefail
# You can set these variables from the command line.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR ?= .
BUILDDIR ?= _build
VENV_NAME := doc_venv
# Put it first so that "make" without argument is like "make help".
help: $(VENV_NAME)
source ./$(VENV_NAME)/bin/activate ;\
$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help lint reload Makefile test
# Create the virtualenv with all the tools installed
$(VENV_NAME):
virtualenv -p python3 $(VENV_NAME) ;\
source ./$(VENV_NAME)/bin/activate ;\
pip install -r requirements.txt
# automatically reload changes in browser as they're made
reload: $(VENV_NAME)
source $</bin/activate ; set -u ;\
sphinx-reload $(SOURCEDIR)
# build multiple versions
multiversion: $(VENV_NAME) Makefile
source $</bin/activate ; set -u ;\
sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
# lint and link verification. linkcheck is built into sphinx
test: lint spelling linkcheck
lint: doc8
doc8: $(VENV_NAME) | $(OTHER_REPO_DOCS)
source $</bin/activate ; set -u ;\
doc8 --max-line-length 119 \
$$(find . -name \*.rst ! -path "*venv*" ! -path "*vendor*" ! -path "*repos*" )
# clean up
clean:
rm -rf $(BUILDDIR)
clean-all: clean
rm -rf $(VENV_NAME)
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: $(VENV_NAME) | $(OTHER_REPO_DOCS)
source $</bin/activate ; set -u ;\
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)