Skip to content

Commit 7aa2175

Browse files
committed
Added docs-live-lang session to nox
1 parent 16ba793 commit 7aa2175

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

noxfile.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# Sphinx-autobuild ignore and include parameters
3232
AUTOBUILD_IGNORE = [
3333
"_build",
34+
".nox",
3435
"build_assets",
3536
"tmp",
3637
]
@@ -63,17 +64,40 @@ def docs_test(session):
6364
# When building the guide with testing parameters, also build the translations with those parameters
6465
session.notify("translation-build", TEST_PARAMETERS)
6566

67+
# This session will build the guide in English, to use it with a translation during development,
68+
# pass the language as a parameter to sphinx-build via nox with (example for Spanish):
69+
# nox -s docs-live -- -D language=es
6670
@nox.session(name="docs-live")
6771
def docs_live(session):
6872
"""Build and launch a local copy of the guide."""
6973
session.install("-e", ".")
7074
cmd = [SPHINX_AUTO_BUILD, *BUILD_PARAMETERS, SOURCE_DIR, OUTPUT_DIR, *session.posargs]
7175
for folder in AUTOBUILD_IGNORE:
7276
cmd.extend(["--ignore", f"*/{folder}/*"])
73-
# for folder in AUTOBUILD_INCLUDE:
77+
# for folder in AUTOBUILD_INCLUDE: # This was commented in the original nox file
7478
# cmd.extend(["--watch", folder])
7579
session.run(*cmd)
7680

81+
@nox.session(name="docs-live-lang")
82+
def docs_live_lang(session):
83+
"""A convenience session for beginner contributors to use docs-live with a language translation."""
84+
if not session.posargs:
85+
session.error(
86+
"Please provide a language using:\n\n "
87+
"nox -s docs-live-lang -- LANG\n\n "
88+
f" where LANG is one of: {LANGUAGES}"
89+
)
90+
lang = session.posargs[0]
91+
if lang in LANGUAGES:
92+
session.posargs.pop(0)
93+
session.notify("docs-live", ('-D', f"language={lang}", *session.posargs))
94+
else:
95+
session.error(
96+
f"[{lang}] locale is not available. Try using:\n\n "
97+
"nox -s docs-live-lang -- LANG\n\n "
98+
f"where LANG is one of: {LANGUAGES}"
99+
)
100+
77101
@nox.session(name="docs-clean")
78102
def clean_dir(session):
79103
"""Clean out the docs directory used in the live build."""

0 commit comments

Comments
 (0)