forked from orzih/mkdocs-with-pdf
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (117 loc) · 3.33 KB
/
Makefile
File metadata and controls
133 lines (117 loc) · 3.33 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
at ?= @
makefile_directory := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
.PHONY: help
help:
@echo "Usage:"
@echo " all : clean, setup, sync, build, check, docs, samples"
@echo " build : build wheel and compressed source"
@echo " check : run pre-commit"
@echo " clean : delete all generated content"
@echo " distclean : delete the venv and all cached data"
@echo " docs : build the documentation"
@echo " publish : publish to PyPi"
@echo " samples : build the samples"
@echo " setup : make a venv"
@echo " sync : fill the venv"
venv := $(makefile_directory)/.venv
activate := $(venv)/bin/activate
$(activate):
@echo "########"
@echo "# venv #"
@echo "########"
$(at)uv --directory $(makefile_directory) venv
@echo ""
.PHONY: setup
setup: $(activate)
.PHONY: sync
sync: setup
@echo "########"
@echo "# sync #"
@echo "########"
$(at)git -C $(makefile_directory) submodule update --init --recursive
$(at). $(activate) \
&& uv --directory $(makefile_directory) lock \
&& uv --directory $(makefile_directory) sync --extra all
@echo ""
$(makefile_directory)/.git/hooks/pre-commit:
@echo "###############"
@echo "# setup-check #"
@echo "###############"
$(at). $(activate) \
&& cd $(makefile_directory) \
&& pre-commit install
@echo ""
.PHONY: setup-check
setup-check: $(makefile_directory)/.git/hooks/pre-commit
.PHONY: check
check: sync setup-check
@echo "#########"
@echo "# check #"
@echo "#########"
$(at). $(activate) \
&& pre-commit run --all-files
@echo ""
.PHONY: build
build: sync
@echo "#########"
@echo "# build #"
@echo "#########"
$(at). $(activate) \
&& uv --directory $(makefile_directory) lock \
&& uv --directory $(makefile_directory) build
@echo ""
.PHONY: docs
docs: sync
@echo "########"
@echo "# docs #"
@echo "########"
$(at). $(activate) \
&& cd $(makefile_directory) \
&& mkdocs build
@echo ""
.PHONY: samples
samples: sync
@echo "###########"
@echo "# samples #"
@echo "###########"
$(at)$(MAKE) -C samples/mkdocs build
$(at)$(MAKE) -C samples/mkdocs-material build
@echo ""
.PHONY: all
all: clean check docs samples build
token_argument = $(shell \
if [ -f $(makefile_directory)/.token ]; then \
echo "--token $$(cat $(makefile_directory)/.token)"; \
else \
echo ""; \
fi)
.PHONY: publish
publish: all
@echo "###########"
@echo "# publish #"
@echo "###########"
$(at)uv --directory $(makefile_directory) publish $(token_argument)
@echo ""
.PHONY: clean
clean:
$(at)rm -rf \
$(makefile_directory)/dist/ \
$(makefile_directory)/docs/build/
$(at)$(MAKE) -C $(makefile_directory)/samples/mkdocs clean
$(at)$(MAKE) -C $(makefile_directory)/samples/mkdocs-material clean
.PHONY: distclean
distclean: clean
$(at)rm -rf \
$(makefile_directory)/.aider* \
$(makefile_directory)/.cache \
$(makefile_directory)/.coverage \
$(makefile_directory)/.coverage.xml \
$(makefile_directory)/.htmlcov \
$(makefile_directory)/.junit.xml \
$(makefile_directory)/.pytest_cache \
$(makefile_directory)/.ruff_cache \
$(venv)
$(at)find $(makefile_directory) -type d -name ".mypy_cache" -exec rm -rf {} +
$(at)find $(makefile_directory) -type d -name "__pycache__" -exec rm -rf {} +
$(at)$(MAKE) -C $(makefile_directory)/samples/mkdocs distclean
$(at)$(MAKE) -C $(makefile_directory)/samples/mkdocs-material distclean