Zack Williams | 7f708f8 | 2020-07-07 12:18:20 -0700 | [diff] [blame] | 1 | # Makefile for Sphinx documentation |
| 2 | |
| 3 | # use bash for pushd/popd, and to fail quickly |
| 4 | SHELL = bash -e -o pipefail |
| 5 | |
| 6 | # You can set these variables from the command line. |
| 7 | SPHINXOPTS ?= |
| 8 | SPHINXBUILD ?= sphinx-build |
| 9 | SOURCEDIR ?= . |
| 10 | BUILDDIR ?= _build |
| 11 | |
| 12 | # name of python virtualenv that is used to run commands |
| 13 | VENV_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". |
| 18 | help: $(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 | virtualenv -p python3 $(VENV_NAME) ;\ |
| 25 | source $@/bin/activate ;\ |
| 26 | pip install -r requirements.txt |
| 27 | |
| 28 | # automatically reload changes in browser as they're made |
| 29 | reload: $(VENV_NAME) |
| 30 | source $</bin/activate ; set -u ;\ |
| 31 | sphinx-reload $(SOURCEDIR) |
| 32 | |
| 33 | # lint and link verification. linkcheck is part of sphinx |
| 34 | test: lint linkcheck spelling |
| 35 | |
| 36 | lint: doc8 |
| 37 | |
| 38 | doc8: $(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 | license: $(VENV_NAME) |
| 44 | source $</bin/activate ; set -u ;\ |
| 45 | reuse --version ;\ |
| 46 | reuse --root . lint |
| 47 | |
| 48 | # clean up |
| 49 | clean: |
| 50 | rm -rf $(BUILDDIR) |
| 51 | |
| 52 | clean-all: clean |
| 53 | rm -rf $(VENV_NAME) |
| 54 | |
| 55 | # build multiple versions |
| 56 | multiversion: $(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) |