Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 1 | # Makefile for VPP Test documentation |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 2 | # |
| 3 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 4 | SPHINXOPTS = |
Klement Sekera | b8c72a4 | 2018-11-08 11:21:39 +0100 | [diff] [blame] | 5 | SRC_DOC_DIR = $(TEST_DIR)/doc |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 6 | SPHINXBUILD = sphinx-build |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 7 | HTML_DOC_GEN_DIR = $(TEST_DOC_BR)/html |
| 8 | API_DOC_GEN_DIR = $(TEST_DOC_BR)/api |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 9 | |
| 10 | # Internal variables. |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 11 | ALLSPHINXOPTS = -d $(TEST_DOC_BR)/.sphinx-cache $(SPHINXOPTS) $(API_DOC_GEN_DIR) -c $(SRC_DOC_DIR) |
Klement Sekera | b8c72a4 | 2018-11-08 11:21:39 +0100 | [diff] [blame] | 12 | IN_VENV:=$(shell if pip -V | grep "venv" 2>&1 > /dev/null; then echo 1; else echo 0; fi) |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 13 | |
| 14 | .PHONY: verify-virtualenv |
| 15 | verify-virtualenv: |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 16 | ifndef TEST_DIR |
| 17 | $(error TEST_DIR is not set) |
| 18 | endif |
| 19 | ifndef TEST_DOC_BR |
| 20 | $(error TEST_DOC_BR is not set) |
| 21 | endif |
| 22 | ifndef BUILD_TEST_SRC |
| 23 | $(error BUILD_TEST_SRC is not set) |
| 24 | endif |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 25 | ifeq ($(IN_VENV),0) |
| 26 | $(error "Not running inside virtualenv (are you running 'make test-doc' from root?)") |
| 27 | endif |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 28 | |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 29 | .PHONY: regen-api-doc |
| 30 | regen-api-doc: verify-virtualenv |
| 31 | @mkdir -p $(API_DOC_GEN_DIR) |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 32 | @cp $(SRC_DOC_DIR)/index.rst $(API_DOC_GEN_DIR) |
Klement Sekera | e7c034b | 2017-01-26 14:54:47 +0100 | [diff] [blame] | 33 | @cp $(SRC_DOC_DIR)/indices.rst $(API_DOC_GEN_DIR) |
| 34 | @cp $(SRC_DOC_DIR)/overview.rst $(API_DOC_GEN_DIR) |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 35 | sphinx-apidoc -o $(API_DOC_GEN_DIR) -H "Module documentation" $(BUILD_TEST_SRC) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 36 | |
| 37 | .PHONY: html |
Matej Klotton | 86d87c4 | 2016-11-11 11:38:55 +0100 | [diff] [blame] | 38 | html: regen-api-doc verify-virtualenv |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 39 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(HTML_DOC_GEN_DIR) |