Skip to content

Commit bf28928

Browse files
authored
Merge pull request #34 from dbatten5/add-docs-session
Add `docs` nox session
2 parents 8fbc4ce + 9cc43c6 commit bf28928

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

{{cookiecutter.project_name}}/noxfile.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,21 @@ def docs_build(session: Session) -> None:
199199
session.log("Building documentation.")
200200
session.run("sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-W")
201201

202+
@nox.session(python=DEFAULT_PYTHON_VERSION, name="docs", tags=[DOCS, BUILD])
203+
def docs(session: Session) -> None:
204+
"""Build and serve the project documentation (Sphinx)."""
205+
session.log("Installing documentation dependencies...")
206+
session.install("-e", ".", "--group", "docs")
207+
208+
session.log(f"Building documentation with py{session.python}.")
209+
docs_build_dir = Path("docs") / "_build" / "html"
210+
211+
session.log(f"Cleaning build directory: {docs_build_dir}")
212+
session.run("sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-E")
213+
214+
session.log("Building and serving documentation.")
215+
session.run("sphinx-autobuild", "--open-browser", "docs", str(docs_build_dir))
216+
202217

203218
@nox.session(python=False, name="build-python", tags=[BUILD])
204219
def build_python(session: Session) -> None:

{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ docs = [
4040
"furo>=2024.8.6",
4141
"myst-parser>=3.0.1",
4242
"sphinx>=7.4.7",
43+
"sphinx-autobuild>=2024.10.3",
4344
"sphinx-autodoc-typehints>=2.3.0",
4445
"sphinx-copybutton>=0.5.2",
4546
"sphinx-tabs>=3.4.7",

0 commit comments

Comments
 (0)