-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
90 lines (79 loc) · 2.45 KB
/
Makefile
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Minimal makefile for Sphinx documentation
#
# Override options by using {VAR}={VALUE} on the CLI.
#
# make html SPXBUILDDIR=/tmp/other
#
# Sphinx settings
SPXOPTS ?=
SPXBUILD ?= sphinx-build
SPXSRCDIR = source
SPXDIR = sphinx
SPXVENVDIR = /opt/venvs/sphinx-docs
SPXVENV = $(SPXVENVDIR)/bin/activate
SPXBUILDDIR = /tmp/docs
SPXTARGETDIR = docs
help:
@echo " make deps"
@echo " Install required package dependencies for doc generation."
@echo
@echo " make install"
@echo " Install virtual environment for sphinx doc generation."
@echo
@echo " make purge_cache"
@echo " Purges docs Python cache, build cache."
@echo
@echo " make clean"
@echo " Removes all doc build artifacts & virtual environment."
@echo
@echo " make html"
@echo " Build non-optimized docs in $(SPXBUILDDIR). Used for testing."
@echo
@echo " make linkcheck"
@echo " Verifies docs links resolve properly."
@echo
@echo " make copy"
@echo " Copies optimized docs in $(SPXBUILDDIR) to $(SPXTARGETDIR)."
@echo " Use 'make docs' or 'make docs_html'."
@echo
@echo " make docs"
@echo " Build optimized docs in $(SPXBUILDDIR) to $(SPXTARGETDIR)."
@echo " COMMON COMMAND."
.PHONY: help Makefile
deps:
@echo 'Verifying sphinx dependencies ...'
ifeq ($(OS_ID),debian)
@sudo apt install python3-pip python3-venv
endif
ifeq ($(OS_ID),manjaro)
@sudo pacman -Syu python-pip python-virtualenv
endif
@echo 'Done.'
install:
@echo 'Setting up sphinx python virtual environment ...'
@sudo mkdir -p $(SPXVENVDIR)
@sudo chown $(USER):$(USER) $(SPXVENVDIR)
@python3 -m venv $(SPXVENVDIR)
@. $(SPXVENV); python3 -m pip install --quiet --requirement $(SPXDIR)/requirements.txt
@echo 'Done.'
purge_cache:
@echo 'Cleaning sphinx cache ...'
-@rm -rfv "$(SPXBUILDDIR)"
-@find "$(SPXDIR)" -type d -name '__pycache__' -exec rm -rfv {} \;
@echo 'Done.'
clean: purge_cache
@echo 'Cleaning sphinx directories ...'
-@rm -rfv "$(SPXVENVDIR)"
@echo 'Done.'
html:
@. $(SPXVENV); $(SPXBUILD) -M html "$(SPXSRCDIR)" "$(SPXBUILDDIR)" -j auto -c "$(SPXDIR)" $(SPXOPTS) $(O)
linkcheck:
@. $(SPXVENV); $(SPXBUILD) -M linkcheck "$(SPXSRCDIR)" "$(SPXBUILDDIR)" -j auto -c "$(SPXDIR)" $(SPXOPTS) $(O)
copy:
@mkdir -p $(SPXTARGETDIR)
@touch $(SPXTARGETDIR)/.nojekyll
@cp -av $(SPXBUILDDIR)/html/* "$(SPXTARGETDIR)"
@rm -v "$(SPXTARGETDIR)/objects.inv"
@rm -v "$(SPXTARGETDIR)/genindex.html"
@rm -rfv "$(SPXTARGETDIR)/_sources"
docs: html copy