aboutsummaryrefslogtreecommitdiffstats
path: root/test/doc/Makefile
blob: 608df0a1baf70af154b109de9504738b1b4b0608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Makefile for VPP Test documentation
#

SPHINXOPTS    =
SRC_DOC_DIR = $(TEST_DIR)/doc
SPHINXBUILD = sphinx-build
HTML_DOC_GEN_DIR = $(TEST_DOC_BR)/html
API_DOC_GEN_DIR = $(TEST_DOC_BR)/api

# Internal variables.
ALLSPHINXOPTS   = -d $(TEST_DOC_BR)/.sphinx-cache $(SPHINXOPTS) $(API_DOC_GEN_DIR) -c $(SRC_DOC_DIR)
IN_VENV:=$(shell if pip -V | grep "venv" 2>&1 > /dev/null; then echo 1; else echo 0; fi)

.PHONY: verify-virtualenv
verify-virtualenv:
ifndef TEST_DIR
	$(error TEST_DIR is not set)
endif
ifndef TEST_DOC_BR
	$(error TEST_DOC_BR is not set)
endif
ifndef BUILD_TEST_SRC
	$(error BUILD_TEST_SRC is not set)
endif
ifeq ($(IN_VENV),0)
	$(error "Not running inside virtualenv (are you running 'make test-doc' from root?)")
endif

.PHONY: regen-api-doc
regen-api-doc: verify-virtualenv
	@mkdir -p $(API_DOC_GEN_DIR)
	@cp $(SRC_DOC_DIR)/index.rst $(API_DOC_GEN_DIR)
	@cp $(SRC_DOC_DIR)/indices.rst $(API_DOC_GEN_DIR)
	@cp $(SRC_DOC_DIR)/overview.rst $(API_DOC_GEN_DIR)
	sphinx-apidoc -o $(API_DOC_GEN_DIR) -H "Module documentation" $(BUILD_TEST_SRC)

.PHONY: html
html: regen-api-doc verify-virtualenv
	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(HTML_DOC_GEN_DIR)