-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
121 lines (104 loc) · 3.33 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
DIST=$(CURDIR)/dist
SRC=$(CURDIR)/src
IMAGES=$(CURDIR)/images
VENV=$(CURDIR)/.venv
BUILD=$(CURDIR)/.build
texSvgFiles := $(wildcard $(IMAGES)/*.svg.tex)
svgFiles := $(texSvgFiles:$(IMAGES)/%.svg.tex=$(SRC)/images/_generated/%.svg)
texPngFiles := $(wildcard $(IMAGES)/*.png.tex)
pngFiles := $(texPngFiles:$(IMAGES)/%.png.tex=$(SRC)/images/_generated/%.png)
.PHONY: all prod images spelling linkcheck doctest dev dev-images clean
all: prod
$(VENV)/bin/activate: requirements.txt
@echo "Setting up development virtual env in .venv"
python -m venv .venv; \
. .venv/bin/activate; \
python -m pip install --upgrade pip; \
python -m pip install wheel; \
python -m pip install -r requirements.txt
$(SRC)/images/_generated/%.svg: $(IMAGES)/%.svg.tex
mkdir -p $(BUILD)/images
cd $(IMAGES) && pdflatex \
-shell-escape \
-halt-on-error \
-file-line-error \
-interaction nonstopmode \
-output-directory=$(BUILD)/images \
$*.svg.tex
pdf2svg $(BUILD)/images/$*.svg.pdf $(SRC)/images/_generated/$*.svg
$(SRC)/images/_generated/%.png: $(IMAGES)/%.png.tex
mkdir -p $(BUILD)/images/_generated
cd $(IMAGES) && pdflatex \
-shell-escape \
-halt-on-error \
-file-line-error \
-interaction nonstopmode \
-output-directory=$(BUILD)/images \
$*.png.tex
cd $(BUILD)/images && \
pdf2svg $*.png.pdf $*.svg && \
rsvg-convert $*.svg -o $(SRC)/images/_generated/$*.png
$(SRC)/_static/images/favicon.png: $(SRC)/images/_generated/favicon.svg
mkdir -p $(SRC)/images/_generated
rsvg-convert -h 180 $(SRC)/images/_generated/favicon.svg -o $(SRC)/_static/images/favicon.png
images: $(svgFiles) $(pngFiles) $(SRC)/_static/images/favicon.png
spelling: $(VENV)/bin/activate images
. $(VENV)/bin/activate; \
sphinx-build \
-anEb spelling \
$(SRC) \
$(DIST)
linkcheck: $(VENV)/bin/activate images
. $(VENV)/bin/activate; \
sphinx-build \
-anEb linkcheck \
$(SRC) \
$(DIST)
doctest: $(VENV)/bin/activate images
. $(VENV)/bin/activate; \
sphinx-build \
-anEb doctest \
$(SRC) \
$(DIST)
$(DIST): $(VENV)/bin/activate images spelling
. $(VENV)/bin/activate; \
sphinx-build \
-anEWb html \
$(SRC) \
$(DIST)
# Clean unused files inherited from default theme
rm -rf $(DIST)/.doctrees \
$(DIST)/.buildinfo \
$(DIST)/genindex.html \
$(DIST)/objects.inv \
$(DIST)/search.html \
$(DIST)/searchindex.js \
$(DIST)/_sources \
$(DIST)/_static/opensearch.xml \
$(DIST)/_static/basic.css \
$(DIST)/_static/file.png \
$(DIST)/_static/jquery-3.5.1.js \
$(DIST)/_static/language_data.js \
$(DIST)/_static/minus.png \
$(DIST)/_static/plus.png \
$(DIST)/_static/searchtools.js \
$(DIST)/_static/underscore-1.13.1.js \
prod: $(DIST) linkcheck
dev: $(VENV)/bin/activate $(SRC)/_static/images/favicon.png $(svgFiles)
. $(VENV)/bin/activate; \
sphinx-autobuild \
--host 0.0.0.0 \
--port=0 \
--open-browser \
-a \
$(SRC) \
$(DIST)
dev-images:
while inotifywait -e close_write,create $(IMAGES) $(IMAGES)/*.tex;do \
rm -f $(svgFiles) $(pngFiles); \
$(MAKE) images; \
done
clean:
rm -rf $(DIST) $(VENV) $(BUILD)
rm -f $(SRC)/images/_generated/*.png $(SRC)/images/_generated/*.svg
rm -f $(SRC)/_static/images/favicon.png