-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
makefile
127 lines (102 loc) · 3.16 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
122
123
124
125
126
127
SHELL = /usr/bin/env bash
_python ?= python
# for bump2version, valid options are: major, minor, patch
PART ?= patch
PANDOC = pandoc
pandocArgs = --toc -M date="`date "+%B %e, %Y"`" --wrap=none
RSTs = CHANGELOG.rst README.rst docs/example-output.rst
# Main Targets #################################################################
.PHONY: docs api html test clean
docs: $(RSTs)
$(MAKE) html
api: docs/api/
html: dist/docs/
test:
rm -f .coverage*
$(_python) \
-m coverage run \
-m pytest -vv --workers=auto tests
coverage: test
coverage combine; coverage report
coverage html
coverage xml
clean:
rm -f $(RSTs) .coverage* tests/model-latex.pdf tests/model-html.html
# docs #########################################################################
README.rst: docs/README.md
printf \
"%s\n\n" \
".. This is auto-generated from \`$<\`. Do not edit this file directly." \
> $@
$(PANDOC) $(pandocArgs) $< -V title='pandoc-amsthm Documentation' -s -t rst -o $@
%.rst: %.md
printf \
"%s\n\n" \
".. This is auto-generated from \`$<\`. Do not edit this file directly." \
> $@
$(PANDOC) $(pandocArgs) $< -s -t rst >> $@
docs/api/:
sphinx-apidoc \
--maxdepth 6 \
--force \
--separate \
--module-first \
--implicit-namespaces \
--doc-project API \
--output-dir $@ src/amsthm
dist/docs/:
sphinx-build -E -b dirhtml docs dist/docs
sphinx-build -b linkcheck docs dist/docs
# maintenance ##################################################################
.PHONY: pypi pypiManual gh-pages pep8 flake8 pylint
# Deploy to PyPI
## by CI, properly git tagged
pypi:
git push origin v2.0.0
## Manually
pypiManual:
rm -rf dist
poetry build
twine upload dist/*
gh-pages:
ghp-import --no-jekyll --push dist/docs
# check python styles
pep8:
pycodestyle . --ignore=E501
flake8:
flake8 . --ignore=E501
pylint:
pylint amsthm
print-%:
$(info $* = $($*))
# poetry #######################################################################
setup.py:
poetry build
cd dist; tar -xf amsthm-2.0.0.tar.gz amsthm-2.0.0/setup.py
mv dist/amsthm-2.0.0/setup.py .
rm -rf dist/amsthm-2.0.0
.PHONY: editable
# since poetry doesn't support editable, we can build and extract the setup.py,
# temporary remove pyproject.toml and ask pip to install from setup.py instead.
editable: setup.py
mv pyproject.toml .pyproject.toml
$(_python) -m pip install --no-dependencies -e .
mv .pyproject.toml pyproject.toml
# releasing ####################################################################
.PHONY: bump
bump:
bump2version $(PART)
git push --follow-tags
# test files ###################################################################
target: tests/model-target.md tests/model-latex.tex
demo: tests/model-latex.pdf tests/model-html.html
tests/model-target.md: tests/model-source.md
pandoc -F amsthm $< -o $@
tests/model-latex.tex: tests/model-source.md
pandoc -F amsthm $< -o $@ --top-level-division=chapter --toc -N
tests/model-latex.pdf: tests/model-source.md
pandoc -F amsthm $< -o $@ --top-level-division=chapter --toc -N
tests/model-html.html: tests/model-source.md
pandoc -F amsthm $< -o $@ --toc -N -s
docs/example-output.rst: tests/model-source.md
pandoc -F amsthm $< -o $@ --toc -N -s