forked from NannyML/nannyml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
84 lines (61 loc) · 1.77 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
sources = nannyml
.PHONY: test format lint unittest coverage pre-commit clean
test: format lint unittest
BROWSER = python -m webbrowser
format:
isort $(sources) tests
black $(sources) tests
lint:
flake8 $(sources) tests
mypy $(sources) tests
doc8 docs
unittest:
pytest
coverage:
pytest --cov=$(sources) --cov-branch --cov-report=term-missing tests
pre-commit:
pre-commit run --all-files
clean:
rm -rf .mypy_cache .pytest_cache
rm -rf *.egg-info
rm -rf .tox dist site
rm -rf coverage.xml .coverage
find . -type d -name __pycache__ -exec rm -r {} \+
clean-docs:
rm -rf docs/nannyml
$(MAKE) -C docs clean
test-notebooks:
python docs/run_notebooks.py "docs/example_notebooks/*.ipynb"
build-docs:
$(MAKE) -C docs html
serve-docs:
$(BROWSER) docs/_build/html/index.html
docs: clean-docs test-notebooks build-docs serve-docs
# For some reason make docs doesn't work!
# $ make docs
# make: 'docs' is up to date.
#
# Let's define a small python script to serve docs
define BROWSER_PYSCRIPT
from os import chdir
from http.server import HTTPServer, SimpleHTTPRequestHandler
# Hardcode/Move to appropriate directory
chdir('./docs/_build/html/')
print("http://localhost:8001/")
# Create server object listening the port 8001
server = HTTPServer(server_address=('', 8001), RequestHandlerClass=SimpleHTTPRequestHandler)
# Start the web server
server.serve_forever()
endef
export BROWSER_PYSCRIPT
showdocs: ## generate Sphinx HTML documentation, including API docs
rm -rf docs/nannyml
#sphinx-apidoc -o docs/nannyml nannyml tests nannyml/datasets/data
$(MAKE) -C docs clean
python docs/run_notebooks.py "docs/example_notebooks/*.ipynb"
$(MAKE) -C docs html
python -c "$$BROWSER_PYSCRIPT"
# Use Ctrl+C to stop serving docs.
# custom serve
cserve-docs:
python -c "$$BROWSER_PYSCRIPT"