-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
116 lines (101 loc) · 3.49 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
.ONESHELL: all
.DEFAULT: help
VERSION := $(shell sed -n 's/^version = //gp' pyproject.toml | tr -d '"')
DOCSDIR := "docs/.sphinx"
GITHUB_URL := "https://github.com/andres-fr/skerch"
help:
@echo "docs-prepare"
@echo " Build the documentation"
@echo "docs-html"
@echo " Build the documentation as HTML. Requires docs-prepare"
@echo "docs-pdf"
@echo " Build the documentation as PDF. Requires docs-prepare"
#
@echo "docs"
@echo " Runs docs-prepare docs-html docs-pdf"
@echo "isort"
@echo " Runs isort, formats Python imports"
@echo "black"
@echo " Runs black, formats Python code"
@echo "flake8"
@echo " Runs flake8, a Python linter"
@echo "pydocstyle"
@echo " Runs pydocstyle, lints and checks style of documentation"
@echo "lint"
@echo " Runs isort black flake8 pydocstyle"
#
@echo "test"
@echo " Runs all pytests in 'test' plus coverage"
@echo "test-light"
@echo " Runs lightweight (yet fairly comprehensive) subset of"
@echo " pytests in 'test' plus coverage"
@echo "test-ci"
@echo " CI-friendly version of tests, subset of test-light"
.PHONY: docs-prepare
docs-prepare:
# start sphinx dir from scratch and configure
@rm -rf $(DOCSDIR); mkdir -p $(DOCSDIR)
@sphinx-quickstart -l en -p skerch -a aferro -v $(VERSION) -r $(VERSION) \
--ext-githubpages --ext-autodoc --ext-mathjax --ext-viewcode \
--ext-coverage --ext-intersphinx --ext-githubpages \
--ext-doctest --no-sep \
--extensions=sphinx_rtd_theme,sphinx.ext.graphviz,sphinx.ext.autosectionlabel,sphinx_gallery.gen_gallery,sphinx_immaterial.task_lists \
$(DOCSDIR)
@echo 'sphinx_gallery_conf = {"examples_dirs": "../materials/examples", \
"gallery_dirs": "examples", \
"default_thumb_file": "docs/materials/assets/skerch_logo.svg", \
"remove_config_comments": True, "filename_pattern": "example", \
"matplotlib_animations": True}' >> $(DOCSDIR)/conf.py
# incorporate apidocs and custom materials
@sphinx-apidoc -M -o $(DOCSDIR) skerch -T \
-t docs/materials/apidoc_templates
@cp docs/materials/*.rst $(DOCSDIR)
# Add metadata to all rst files ("edit on GitHub" link):
for path in $(shell find $(DOCSDIR) -iname "*.rst");
do
@echo "adding GH link to" $$path
@sed -i '1i:github_url: '$(GITHUB_URL)'\n' "$$path"
done
.PHONY: docs-html
docs-html:
@sphinx-build -M html $(DOCSDIR) $(DOCSDIR)/_build \
-D html_theme="sphinx_rtd_theme" \
-D html_favicon=../materials/assets/favicon.ico \
-D html_logo=../materials/assets/skerch_horizontal.svg \
-D html_theme_options.logo_only=true \
-D suppress_warnings="autosectionlabel" \
-W
.PHONY: docs-pdf
docs-pdf:
@sphinx-build -M latexpdf $(DOCSDIR) $(DOCSDIR)/_build \
-D html_theme="sphinx_rtd_theme" \
-D html_favicon=../materials/assets/favicon.ico \
-D html_logo=../materials/assets/skerch_horizontal.svg \
-D suppress_warnings="autosectionlabel" \
-D html_theme_options.logo_only=true
.PHONY: docs
docs: docs-prepare docs-html docs-pdf
.PHONY: isort
isort:
@isort . --sp pyproject.toml
.PHONY: black
black:
@black . --config pyproject.toml
.PHONY: flake8
flake8:
@flake8 .
.PHONY: pydocstyle
pydocstyle:
@pydocstyle . --config pyproject.toml # --count
.PHONY: lint
lint: isort black flake8 pydocstyle
.PHONY: test
test:
@pytest -vx test --cov skerch
.PHONY: test-light
test-light:
@pytest -vx test --cov skerch --quick --seeds='12345'
.PHONY: test-ci
test-ci:
@pytest -vx test --cov skerch --quick --seeds='12345' \
--skip_toomanyfiles