Skip to content

Commit 7ac1a2f

Browse files
committed
add session to build generated docs
1 parent cac1411 commit 7ac1a2f

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
__pycache__/
66
build/
77
dist/
8+
docs/_generated/

docs/api/index.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Developer Documentation
2-
-----------------------
1+
Python API for ``bmi-tester``
2+
-----------------------------
33

44
.. toctree::
55
:maxdepth: 2
66

7-
modules
7+
/_generated/api/bmi_tester

noxfile.py

+50-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import nox
88

9-
PROJECT = "bmi-tester"
9+
PROJECT = "bmi_tester"
1010
ROOT = pathlib.Path(__file__).parent
1111
PYTHON_VERSION = "3.12"
1212

@@ -54,6 +54,55 @@ def build(session: nox.Session) -> None:
5454
session.run("python", "-m", "build", "--outdir", "./build/wheelhouse")
5555

5656

57+
@nox.session(name="build-docs")
58+
def build_docs(session: nox.Session) -> None:
59+
"""Build the docs."""
60+
61+
build_generated_docs(session)
62+
63+
session.install(
64+
*("-r", "requirements-docs.txt"),
65+
*("-r", "requirements.txt"),
66+
)
67+
session.install(".")
68+
69+
pathlib.Path("build").mkdir(exist_ok=True)
70+
71+
session.run(
72+
"sphinx-build",
73+
"-b",
74+
"html",
75+
"-W",
76+
"--keep-going",
77+
"docs",
78+
"build/html",
79+
)
80+
session.log(f"generated docs at build/html")
81+
82+
83+
@nox.session(name="build-generated-docs", reuse_venv=True)
84+
def build_generated_docs(session: nox.Session) -> None:
85+
"""Build auto-generated files used by the docs."""
86+
# FOLDER["docs_generated"].mkdir(exist_ok=True)
87+
88+
session.install("sphinx")
89+
session.install("-e", ".")
90+
91+
with session.chdir(ROOT):
92+
os.makedirs("src/docs/_generated/api", exist_ok=True)
93+
session.log("generating api docs in docs/api")
94+
session.run(
95+
"sphinx-apidoc",
96+
"-e",
97+
"-force",
98+
"--no-toc",
99+
"--module-first",
100+
"-o",
101+
"docs/_generated/api",
102+
"src/bmi_tester",
103+
)
104+
105+
57106
@nox.session(name="publish-testpypi")
58107
def publish_testpypi(session):
59108
"""Publish wheelhouse/* to TestPyPI."""

0 commit comments

Comments
 (0)