blob: 471713a3ac0d00811ba3d085b41393eebd1a5169 [file] [log] [blame]
Zack Williams36451912022-03-04 20:31:37 -07001# Minimal makefile for Sphinx documentation
2
3# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
4# SPDX-License-Identifier: Apache-2.0
5
6SHELL = bash -e -o pipefail
7
8# You can set these variables from the command line.
9SPHINXOPTS = -W
10SPHINXBUILD = sphinx-build
11SOURCEDIR = .
12BUILDDIR = _build
13
14# Create the virtualenv with all the tools installed
15VIRTUALENV = venv-docs
16
17# Put it first so that "make" without argument runs "make help".
18help: $(VIRTUALENV)
19 source ./$(VIRTUALENV)/bin/activate ;\
20 $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21
22.PHONY: help Makefile lint license test
23# automatically reload changes in browser as they're made
24
25$(VIRTUALENV):
26 python3 -m venv $@ ;\
27 source ./$@/bin/activate ;\
28 pip install -r requirements.txt
29
30# test - check that local build will lint, spelling is correct, then
31# build the html site.
32test: license lint spelling linkcheck
33
34# lint all .rst files
35lint: $(VIRTUALENV)
36 source ./$</bin/activate ; set -u;\
37 doc8 --ignore-path $< --ignore-path _build --ignore-path LICENSES --max-line-length 99
38
39license: $(VIRTUALENV) ## Check license with the reuse tool
40 source ./$</bin/activate ; set -u ;\
41 reuse --version ;\
42 reuse --root . lint
43
44# clean up
45clean:
46 rm -rf "$(BUILDDIR)"
47
48# clean-all - delete the virtualenv too
49clean-all: clean
50 rm -rf "$(VIRTUALENV)"
51
52# Catch-all target: route all unknown targets to Sphinx using the new
53# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
54%: $(VIRTUALENV) Makefile
55 source ./$</bin/activate ; set -u;\
56 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)