-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
93 lines (81 loc) · 2.85 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
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
PYTHON = python3
VENVDIR = ./.venv
SPHINXBUILD = $(VENVDIR)/bin/sphinx-build
SPHINXOPTS = --fail-on-warning --keep-going
BUILDDIR = _build
BUILDER = html
JOBS = auto
SPHINXLINT = $(VENVDIR)/bin/sphinx-lint
# Internal variables.
ALLSPHINXOPTS = --builder $(BUILDER) \
--doctree-dir $(BUILDDIR)/doctrees \
--jobs $(JOBS) \
$(SPHINXOPTS) \
docs $(BUILDDIR)/$(BUILDER)
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " venv to create a venv with necessary tools"
@echo " html to make standalone HTML files"
@echo " htmlview to open the index page built by the html target in your browser"
@echo " htmllive to rebuild and reload HTML files in your browser"
@echo " clean to remove the venv and build files"
@echo " linkcheck to check all external links for integrity"
@echo " lint to lint all the files"
.PHONY: clean
clean: clean-venv
-rm -rf $(BUILDDIR)/*
.PHONY: clean-venv
clean-venv:
rm -rf $(VENVDIR)
.PHONY: venv
venv:
@if [ -d $(VENVDIR) ] ; then \
echo "venv already exists."; \
echo "To recreate it, remove it first with \`make clean-venv'."; \
else \
$(MAKE) ensure-venv; \
fi
.PHONY: ensure-venv
ensure-venv:
@if [ ! -d $(VENVDIR) ] ; then \
echo "Creating venv in $(VENVDIR)"; \
if uv --version > /dev/null; then \
uv venv $(VENVDIR); \
VIRTUAL_ENV=$(VENVDIR) uv pip install -r requirements.txt; \
else \
$(PYTHON) -m venv $(VENVDIR); \
$(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
fi; \
echo "The venv has been created in the $(VENVDIR) directory"; \
fi
.PHONY: html
html: ensure-venv
$(SPHINXBUILD) $(ALLSPHINXOPTS)
.PHONY: linkcheck
linkcheck: BUILDER = linkcheck
linkcheck: html
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/$(BUILDER)/output.txt."
.PHONY: htmlview
htmlview: html
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('_build/html/index.html'))"
.PHONY: htmllive
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
# Arbitrarily selected ephemeral port between 49152–65535
# to avoid conflicts with other processes:
htmllive: SPHINXOPTS = --re-ignore="/\.idea/|/venv/" --open-browser --delay 0 --port 55303
htmllive: html
.PHONY: lint
lint: venv
if uv --version > /dev/null; then \
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install pre-commit; \
else \
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit; \
fi;
$(VENVDIR)/bin/python3 -m pre_commit run --all-files