|
31 | 31 | # Sphinx-autobuild ignore and include parameters
|
32 | 32 | AUTOBUILD_IGNORE = [
|
33 | 33 | "_build",
|
| 34 | + ".nox", |
34 | 35 | "build_assets",
|
35 | 36 | "tmp",
|
36 | 37 | ]
|
@@ -63,17 +64,40 @@ def docs_test(session):
|
63 | 64 | # When building the guide with testing parameters, also build the translations with those parameters
|
64 | 65 | session.notify("translation-build", TEST_PARAMETERS)
|
65 | 66 |
|
| 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 |
66 | 70 | @nox.session(name="docs-live")
|
67 | 71 | def docs_live(session):
|
68 | 72 | """Build and launch a local copy of the guide."""
|
69 | 73 | session.install("-e", ".")
|
70 | 74 | cmd = [SPHINX_AUTO_BUILD, *BUILD_PARAMETERS, SOURCE_DIR, OUTPUT_DIR, *session.posargs]
|
71 | 75 | for folder in AUTOBUILD_IGNORE:
|
72 | 76 | 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 |
74 | 78 | # cmd.extend(["--watch", folder])
|
75 | 79 | session.run(*cmd)
|
76 | 80 |
|
| 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 | + |
77 | 101 | @nox.session(name="docs-clean")
|
78 | 102 | def clean_dir(session):
|
79 | 103 | """Clean out the docs directory used in the live build."""
|
|
0 commit comments