Zack Williams | 3645191 | 2022-03-04 20:31:37 -0700 | [diff] [blame^] | 1 | # Minimal makefile for Sphinx documentation |
| 2 | |
| 3 | # SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | SHELL = bash -e -o pipefail |
| 7 | |
| 8 | # You can set these variables from the command line. |
| 9 | SPHINXOPTS = -W |
| 10 | SPHINXBUILD = sphinx-build |
| 11 | SOURCEDIR = . |
| 12 | BUILDDIR = _build |
| 13 | |
| 14 | # Create the virtualenv with all the tools installed |
| 15 | VIRTUALENV = venv-docs |
| 16 | |
| 17 | # Put it first so that "make" without argument runs "make help". |
| 18 | help: $(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. |
| 32 | test: license lint spelling linkcheck |
| 33 | |
| 34 | # lint all .rst files |
| 35 | lint: $(VIRTUALENV) |
| 36 | source ./$</bin/activate ; set -u;\ |
| 37 | doc8 --ignore-path $< --ignore-path _build --ignore-path LICENSES --max-line-length 99 |
| 38 | |
| 39 | license: $(VIRTUALENV) ## Check license with the reuse tool |
| 40 | source ./$</bin/activate ; set -u ;\ |
| 41 | reuse --version ;\ |
| 42 | reuse --root . lint |
| 43 | |
| 44 | # clean up |
| 45 | clean: |
| 46 | rm -rf "$(BUILDDIR)" |
| 47 | |
| 48 | # clean-all - delete the virtualenv too |
| 49 | clean-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) |