-
Notifications
You must be signed in to change notification settings - Fork 17
/
noxfile.py
58 lines (44 loc) · 1.34 KB
/
noxfile.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
import os
import pathlib
import shutil
import nox
ROOT = pathlib.Path(__file__).parent
@nox.session
def lint(session: nox.Session) -> None:
"""Look for lint."""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")
@nox.session(name="build-docs")
def build_docs(session: nox.Session) -> None:
"""Build the docs."""
docs_dir = ROOT / "docs"
build_dir = docs_dir / "build"
session.install("-r", docs_dir / "requirements.txt")
build_dir.mkdir(exist_ok=True)
session.run(
"sphinx-build",
"-b",
"html",
"-W",
"--keep-going",
(docs_dir / "source").as_posix(),
(build_dir / "html").as_posix(),
)
session.log(f"generated docs at {build_dir / 'html'!s}")
@nox.session(python=False, name="clean-docs")
def clean_docs(session: nox.Session) -> None:
"""Clean up the docs folder."""
docs_dir = ROOT / "docs"
if (docs_dir / "build").is_dir():
with session.chdir(docs_dir):
shutil.rmtree("build")
if (ROOT / "build").is_dir():
session.chdir(ROOT / "build")
if os.path.exists("html"):
shutil.rmtree("html")
@nox.session(python=False)
def nuke(session):
"""Run all clean sessions."""
clean_docs(session)
if (ROOT / "__pycache__").is_dir():
shutil.rmtree("__pycache__")