forked from briggySmalls/cookiecutter-pypackage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
40 lines (30 loc) · 799 Bytes
/
tasks.py
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
"""Development tasks for the cookiecutter template project"""
import webbrowser
from pathlib import Path
import platform
from invoke import task
ROOT_DIR = Path(__file__).parent
DOCS_DIR = ROOT_DIR.joinpath('docs')
DOCS_BUILD_DIR = DOCS_DIR.joinpath('_build')
DOCS_INDEX = DOCS_BUILD_DIR.joinpath('index.html')
def _run(c, command):
return c.run(command, pty=platform.system() != 'Windows')
@task
def test(c):
"""
Run tests
"""
_run(c, "pytest")
@task
def docs(c):
"""
Generate documentation
"""
_run(c, "sphinx-build -b html {} {}".format(DOCS_DIR, DOCS_BUILD_DIR))
webbrowser.open(DOCS_INDEX.absolute().as_uri())
@task
def clean_docs(c):
"""
Clean up files from documentation builds
"""
_run(c, "rm -fr {}".format(DOCS_BUILD_DIR))