-
Notifications
You must be signed in to change notification settings - Fork 4
/
noxfile.py
76 lines (61 loc) · 1.61 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
import pathlib
import nox
nox.options.reuse_existing_virtualenvs = True
# Sphinx output and source directories
BUILD_DIR = "_build"
OUTPUT_DIR = pathlib.Path(BUILD_DIR, "html")
SOURCE_DIR = pathlib.Path(".")
# Sphinx build commands
SPHINX_BUILD = "sphinx-build"
SPHINX_AUTO_BUILD = "sphinx-autobuild"
# Sphinx parameters used to build the guide
BUILD_PARAMETERS = ["-b", "html"]
# Sphinx parameters used to test the build of the guide
TEST_PARAMETERS = ["-W", "--keep-going", "-E", "-a"]
# Sphinx-autobuild ignore and include parameters
AUTOBUILD_IGNORE = [
"_build",
".nox",
"build_assets",
"tmp",
]
AUTOBUILD_INCLUDE = [pathlib.Path("_static", "pyos.css")]
@nox.session
def docs(session):
"""Build the handbook"""
session.install("-e", ".")
session.run(
SPHINX_BUILD,
*BUILD_PARAMETERS,
SOURCE_DIR,
OUTPUT_DIR,
*session.posargs,
)
@nox.session(name="docs-live")
def docs_live(session):
session.install("-e", ".")
cmd = [
SPHINX_AUTO_BUILD,
*BUILD_PARAMETERS,
SOURCE_DIR,
OUTPUT_DIR,
*session.posargs,
]
for folder in AUTOBUILD_IGNORE:
cmd.extend(["--ignore", f"*/{folder}/*"])
session.run(*cmd)
@nox.session(name="docs-test")
def docs_test(session):
"""
Build the packaging guide with more restricted parameters.
Note: this is the session used in CI/CD to release the guide.
"""
session.install("-e", ".")
session.run(
SPHINX_BUILD,
*BUILD_PARAMETERS,
*TEST_PARAMETERS,
SOURCE_DIR,
OUTPUT_DIR,
*session.posargs,
)