-
Notifications
You must be signed in to change notification settings - Fork 40
/
noxfile.py
82 lines (70 loc) · 2.45 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
import nox
@nox.session
@nox.parametrize("cocotb", ["1.6.0", "1.9.0", "github-b9dd5ee1"])
def tests(session, cocotb):
if cocotb.startswith("github-"):
cocotb_req = "git+https://github.com/cocotb/cocotb@" + cocotb[len("github-"):]
else:
cocotb_req = f"cocotb=={cocotb}"
session.install("pytest", "coverage", cocotb_req)
session.install(".")
session.run("make", external=True)
def create_env_for_docs_build(session: nox.Session) -> None:
session.run("pip", "install", "-r", "docs/requirements.txt")
@nox.session
def docs(session: nox.Session) -> None:
"""Invoke sphinx-build to build the HTML docs"""
create_env_for_docs_build(session)
session.run("pip", "install", ".")
outdir = session.cache_dir / "docs_out"
session.run("sphinx-build", "./docs/source", str(outdir), "--color", "-b", "html")
index = (outdir / "index.html").resolve().as_uri()
session.log(f"Documentation is available at {index}")
@nox.session
def docs_preview(session: nox.Session) -> None:
"""Build a live preview of the documentation"""
create_env_for_docs_build(session)
# Editable install allows editing cocotb_bus source and seing it updated in the live preview
session.run("pip", "install", "-e", ".")
session.run("pip", "install", "sphinx-autobuild")
outdir = session.cache_dir / "docs_out"
session.run(
"sphinx-autobuild",
# Ignore directories which cause a rebuild loop.
"--ignore",
"*/source/master-notes.rst",
# Also watch the cocotb_bus source directory to rebuild the API docs on
# changes to cocotb_bus code.
"--watch",
"src/cocotb_bus",
"./docs/source",
str(outdir),
)
@nox.session
def docs_linkcheck(session: nox.Session) -> None:
"""Invoke sphinx-build to linkcheck the docs"""
create_env_for_docs_build(session)
session.run("pip", "install", ".")
outdir = session.cache_dir / "docs_out"
session.run(
"sphinx-build",
"./docs/source",
str(outdir),
"--color",
"-b",
"linkcheck",
)
@nox.session
def docs_spelling(session: nox.Session) -> None:
"""Invoke sphinx-build to spellcheck the docs"""
create_env_for_docs_build(session)
session.run("pip", "install", ".")
outdir = session.cache_dir / "docs_out"
session.run(
"sphinx-build",
"./docs/source",
str(outdir),
"--color",
"-b",
"spelling",
)