blob: 471713a3ac0d00811ba3d085b41393eebd1a5169 [file] [log] [blame]
# Minimal makefile for Sphinx documentation
# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
# SPDX-License-Identifier: Apache-2.0
SHELL = bash -e -o pipefail
# You can set these variables from the command line.
SPHINXOPTS = -W
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Create the virtualenv with all the tools installed
VIRTUALENV = venv-docs
# Put it first so that "make" without argument runs "make help".
help: $(VIRTUALENV)
source ./$(VIRTUALENV)/bin/activate ;\
$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile lint license test
# automatically reload changes in browser as they're made
$(VIRTUALENV):
python3 -m venv $@ ;\
source ./$@/bin/activate ;\
pip install -r requirements.txt
# test - check that local build will lint, spelling is correct, then
# build the html site.
test: license lint spelling linkcheck
# lint all .rst files
lint: $(VIRTUALENV)
source ./$</bin/activate ; set -u;\
doc8 --ignore-path $< --ignore-path _build --ignore-path LICENSES --max-line-length 99
license: $(VIRTUALENV) ## Check license with the reuse tool
source ./$</bin/activate ; set -u ;\
reuse --version ;\
reuse --root . lint
# clean up
clean:
rm -rf "$(BUILDDIR)"
# clean-all - delete the virtualenv too
clean-all: clean
rm -rf "$(VIRTUALENV)"
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: $(VIRTUALENV) Makefile
source ./$</bin/activate ; set -u;\
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)