-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
85 lines (71 loc) · 2.18 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
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
85
import nox
# Default sessions
nox.options.sessions = ["docs"]
# Other nox defaults
nox.options.default_venv_backend = "venv"
nox.options.reuse_existing_virtualenvs = True
PIP_DEPENDENCIES = [
("--upgrade", "pip"),
("-r", "docs/requirements.txt"),
]
def _install(session: nox.Session, bin_prefix: str = "") -> None:
"""Install the application and all development dependencies into the
session.
"""
python = f"{bin_prefix}python"
# Install dev dependencies
for deps in PIP_DEPENDENCIES:
session.run(python, "-m", "pip", "install", *deps, external=True)
session.run(
python, "-m", "pip", "install", "nox", external=True
)
@nox.session(name="venv-init")
def init_dev(session: nox.Session) -> None:
"""Set up a documentation venv."""
# Create a venv in the current directory, replacing any existing one
session.run("python", "-m", "venv", ".venv", "--clear")
_install(session, bin_prefix=".venv/bin/")
print(
"\nTo activate this virtual env, run:\n\n\tsource .venv/bin/activate\n"
)
@nox.session(name="init", python=False)
def init(session: nox.Session) -> None:
"""Set up the documentation environment in the current virtual env."""
_install(session, bin_prefix="")
@nox.session
def docs(session: nox.Session) -> None:
"""Build the docs."""
_install(session)
doctree_dir = (session.cache_dir / "doctrees").absolute()
with session.chdir("docs"):
session.run(
"sphinx-build",
"-W",
"--keep-going",
"-n",
"-T",
"-b",
"html",
"-d",
str(doctree_dir),
".",
"./_build/html",
)
@nox.session(name="docs-linkcheck")
def docs_linkcheck(session: nox.Session) -> None:
"""Linkcheck the docs."""
_install(session)
doctree_dir = (session.cache_dir / "doctrees").absolute()
with session.chdir("docs"):
session.run(
"sphinx-build",
"-W",
"--keep-going",
"-n",
"-T",
"-b" "linkcheck",
"-d",
str(doctree_dir),
".",
"./_build/html",
)