blob: 0cdbd726064ca3a35645a6c3d1733f40a3aebf60 [file] [log] [blame]
Charles Chanfcfe8902022-02-02 17:06:27 -08001# SPDX-FileCopyrightText: 2021 Open Networking Foundation <info@opennetworking.org>
2# SPDX-License-Identifier: Apache-2.0
3
Zack Williams98fe2322021-09-20 15:02:11 -07004# Makefile for Sphinx documentation
5
6# use bash for pushd/popd, and to fail quickly
7SHELL = bash -e -o pipefail
8
9# You can set these variables from the command line.
10SPHINXOPTS ?= -W
11SPHINXBUILD ?= sphinx-build
12SOURCEDIR ?= .
13BUILDDIR ?= _build
14
15# name of python virtualenv that is used to run commands
16VENV_NAME := venv-docs
17
18.PHONY: help test lint doc8 reload Makefile prep
19
20# Put it first so that "make" without argument is like "make help".
21help: $(VENV_NAME)
22 source $</bin/activate ; set -u ;\
23 $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24
25# Create the virtualenv with all the tools installed
26$(VENV_NAME):
27 python3 -m venv $(VENV_NAME) ;\
28 source $@/bin/activate ;\
29 pip install -r requirements.txt
30
31# automatically reload changes in browser as they're made
32reload: $(VENV_NAME)
33 source $</bin/activate ; set -u ;\
34 sphinx-reload $(SOURCEDIR)
35
36# lint and link verification. linkcheck is part of sphinx
37test: lint spelling linkcheck
38
39lint: doc8
40
41doc8: $(VENV_NAME) | $(OTHER_REPO_DOCS)
42 source $</bin/activate ; set -u ;\
43 doc8 --max-line-length 119 \
44 $$(find . -name \*.rst ! -path "*venv*" ! -path "*vendor*" ! -path "*repos*" )
45
46license: $(VENV_NAME)
47 source $</bin/activate ; set -u ;\
48 reuse --version ;\
49 reuse --root . lint
50
51# clean up
52clean:
53 rm -rf $(BUILDDIR)
54
55clean-all: clean
56 rm -rf $(VENV_NAME)
57
58# build multiple versions
59multiversion: $(VENV_NAME) Makefile | prep $(OTHER_REPO_DOCS)
60 source $</bin/activate ; set -u ;\
61 sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
62 cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
63
64# Catch-all target: route all unknown targets to Sphinx using the new
65# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
66%: $(VENV_NAME) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
67 source $</bin/activate ; set -u ;\
68 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)