forked from scrapd/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
64 lines (46 loc) · 1.26 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
62
63
64
from pathlib import Path
from invoke import task
from nox.virtualenv import VirtualEnv
DEFAULT_VENV_NAME = 'venv'
@task
def build(c):
"""Build the documentatrion site."""
mkdocs = mkdocs_bin()
c.run(f'{mkdocs} build -v -s')
@task
def clean(c):
"""Remove unwanted files and artifacts in this project (!DESTRUCTIVE!)."""
clean_repo(c)
@task
def clean_repo(c):
"""Remove unwanted files in project (!DESTRUCTIVE!)."""
c.run('git clean -ffdx')
c.run('git reset --hard')
@task
def nox(c, s=''):
"""Wrapper for the nox tasks (`inv nox` for details)."""
if not s:
c.run('nox --list')
else:
c.run(f'nox -s {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 developper environment."""
c.run('nox --envdir .')
def mkdocs_bin():
"""Find mkdocs binary in default venv."""
location = Path(DEFAULT_VENV_NAME)
venv = VirtualEnv(location.resolve())
venv_bin = Path(venv.bin)
mkdocs = venv_bin / 'mkdocs'
return mkdocs