-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
61 lines (49 loc) · 1.54 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from pathlib import Path
from invoke import task
from nox.virtualenv import VirtualEnv
# Configuration values.
VENV = "venv"
@task
def build(c):
"""Build the documentatrion site."""
mkdocs = mkdocs_bin()
c.run(f'{mkdocs} build -v -s')
@task
def publish(c):
"""Publish the site to github pages."""
mkdocs = mkdocs_bin()
c.run(f'{mkdocs} gh-deploy -v --clean')
@task()
def serve(c):
"""Serve the documentation using the development server."""
mkdocs = mkdocs_bin()
c.run(f'{mkdocs} serve')
@task(default=True)
def setup(c):
"""Setup the student environment."""
c.run("python3 -m venv venv")
_, venv_bin, _ = get_venv(VENV)
pip = venv_bin / "pip"
c.run(f"{pip.resolve()} install -U pip setuptools")
c.run(f"{pip.resolve()} install -r requirements.txt -r requirements-dev.txt")
@task
def resize_images(c):
"""Resize images for the BNA document."""
with c.cd("images-orig"):
c.run("mogrify -resize 180x -path ../docs/images *.png")
def get_venv(venv):
"""
Return `Path` objects from the venv.
:param str venv: venv name
:return: the venv `Path`, the `bin` folder `Path` within the venv, and if specified, the `Path` object of the
activate script within the venv.
:rtype: a tuple of 3 `Path` objects.
"""
location = Path(venv)
venv = VirtualEnv(location.resolve())
venv_bin = Path(venv.bin)
activate = venv_bin / "activate"
return venv, venv_bin, activate
def mkdocs_bin():
_,venv_bin,_ = get_venv(VENV)
return venv_bin / "mkdocs"