-
Notifications
You must be signed in to change notification settings - Fork 236
/
noxfile.py
77 lines (56 loc) · 2.26 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
"""Nox sessions."""
from pathlib import Path
import shutil
import nox
from nox.sessions import Session
nox.options.sessions = ["docs"]
owner, repository = "cjolowicz", "cookiecutter-hypermodern-python"
labels = "cookiecutter", "documentation"
bump_paths = "README.md", "docs/guide.rst", "docs/index.rst", "docs/quickstart.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", "docs", "docs/_build"]
if session.interactive and not session.posargs:
args = ["-a", "--watch=docs/_static", "--open-browser", *args]
builddir = Path("docs", "_build")
if builddir.exists():
shutil.rmtree(builddir)
session.install("-r", "docs/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", "docs", "docs/_build"]
builddir = Path("docs", "_build")
if builddir.exists():
shutil.rmtree(builddir)
session.install("-r", "docs/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)