-
Notifications
You must be signed in to change notification settings - Fork 2
/
noxfile.py
89 lines (68 loc) · 2.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
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
86
87
88
89
"""Nox sessions."""
import shutil
from pathlib import Path
import nox
from nox.sessions import Session
nox.options.sessions = ["docs"]
owner, repository = "ylab-hi", "yanglab-guide"
labels = "labguide", "documentation"
bump_paths = (
"README.md",
"source/index.md",
"source/developguide.md",
"source/library.md",
)
@nox.session(name="prepare-release")
def prepare_release(session: Session) -> None:
"""Prepare a GitHub release."""
args = [
f"--owner={owner}",
f"--repository={repository}",
*[f"--bump={path}" for path in bump_paths],
*[f"--label={label}" for label in labels],
*session.posargs,
]
session.install("click", "github3.py")
session.run("python", "tools/prepare-github-release.py", *args, external=True)
@nox.session(name="publish-release")
def publish_release(session: Session) -> None:
"""Publish a GitHub release."""
args = [f"--owner={owner}", f"--repository={repository}", *session.posargs]
session.install("click", "github3.py")
session.run("python", "tools/publish-github-release.py", *args, external=True)
nox.options.sessions = ["linkcheck"]
@nox.session
def docs(session: Session) -> None:
"""Build the documentation."""
args = session.posargs or ["-W", "-n", "source", "source/_build"]
if session.interactive and not session.posargs:
args = ["-a", "--watch=source/_static", "--open-browser", *args]
builddir = Path("source", "_build")
if builddir.exists():
shutil.rmtree(builddir)
session.install("-r", "source/requirements.txt")
if session.interactive:
session.run("sphinx-autobuild", *args)
else:
session.run("sphinx-build", *args)
@nox.session
def linkcheck(session: Session) -> None:
"""Build the documentation."""
args = session.posargs or [
"-b",
"linkcheck",
"-W",
"--keep-going",
"source",
"source/_build",
]
builddir = Path("docs", "_build")
if builddir.exists():
shutil.rmtree(builddir)
session.install("-r", "source/requirements.txt")
session.run("sphinx-build", *args)
@nox.session(name="dependencies-table")
def dependencies_table(session: Session) -> None:
"""Print the dependencies table."""
session.install("tomli")
session.run("python", "tools/dependencies-table.py", external=True)