Skip to content

Commit 264970a

Browse files
committed
fix(docs): gate gallery example execution on TTTRLIB_DOCS_EXECUTE_EXAMPLES
The committed conf.py hard-coded sphinx_gallery_conf['plot_gallery']=True, so the 'Build Documentation' CI job executed every gallery example even though it sets TTTRLIB_DOCS_EXECUTE_EXAMPLES=0 and only provisions a minimal test-data set. Examples whose data is absent hit their 'raise SystemExit(0)' guards; SystemExit derives from BaseException, so sphinx-gallery (which only catches Exception) let it propagate and terminate sphinx-build with exit 0 before the HTML write phase. The job then failed in check_docs_pages.py with 'No HTML pages found'. Gate plot_gallery on TTTRLIB_DOCS_EXECUTE_EXAMPLES (default off), matching the passing rattler docs recipe. With execution off, examples render as source-only gallery pages, the build completes, and the coverage/page checks pass. Also carries the source_suffix/notebook-exclude and theme tweaks staged alongside it.
1 parent 3fa3035 commit 264970a

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

doc/conf.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@
6060
root_doc = "index"
6161
master_doc = "index"
6262

63-
# Accept both .rst and .ipynb as source files
64-
# --- Make sure notebooks are parsed as notebooks ---
65-
# Sphinx 4–7: either form is fine; this one is explicit and robust
66-
source_suffix = {
67-
".rst": "restructuredtext"
68-
}
69-
print("[conf] source_suffix :", source_suffix)
70-
7163
templates_path = ["_templates"] if (HERE / "_templates").exists() else []
7264

7365
# Exclusions (keep minimal at tier 0)
@@ -163,6 +155,18 @@ def _try_import(modname: str) -> bool:
163155
for e in NB_EXTS:
164156
if _try_import(e):
165157
extensions.append(e)
158+
if "nbsphinx" in extensions:
159+
source_suffix = {
160+
".rst": "restructuredtext",
161+
".ipynb": "jupyter_notebook",
162+
}
163+
# Sphinx-Gallery writes notebooks for download. They should not become
164+
# independent source documents because each gallery example already has
165+
# a generated .rst page.
166+
exclude_patterns += [
167+
"auto_examples/**/*.ipynb",
168+
"auto_examples/*.ipynb",
169+
]
166170
# Conservative notebook settings
167171
nbsphinx_execute = "never"
168172
nbsphinx_allow_errors = True
@@ -174,6 +178,12 @@ def _try_import(modname: str) -> bool:
174178
print("[conf] exclude_patterns:", exclude_patterns)
175179
print("[conf] extensions", extensions)
176180

181+
if "source_suffix" not in globals():
182+
source_suffix = {
183+
".rst": "restructuredtext",
184+
}
185+
print("[conf] source_suffix :", source_suffix)
186+
177187
if BUILD_TIER >= 4:
178188
# Headless + no-op show (helps avoid hanger)
179189
os.environ.setdefault("MPLBACKEND", "Agg")
@@ -230,7 +240,7 @@ def _try_import(modname: str) -> bool:
230240
"gallery_dirs": ["auto_examples"],
231241
"filename_pattern": r"plot_.*\.py$",
232242
"ignore_pattern": ignore_pat, # <-- blacklist in effect
233-
"plot_gallery": True,
243+
"plot_gallery": os.environ.get("TTTRLIB_DOCS_EXECUTE_EXAMPLES", "0").lower() in {"1", "true", "yes", "on"},
234244
"image_scrapers": ("matplotlib",),
235245
"reset_modules": ("matplotlib",),
236246
"remove_config_comments": True,
@@ -275,11 +285,9 @@ def _first_available_theme(candidates):
275285
html_domain_indices = False
276286
html_use_index = False
277287

278-
# Theme options kept minimal to reduce breakage
279-
html_theme_options = {
280-
"navigation_depth": 3,
281-
"show_toc_level": 2,
282-
}
288+
html_theme_options = {"navigation_depth": 3}
289+
if html_theme == "pydata_sphinx_theme":
290+
html_theme_options["show_toc_level"] = 2
283291

284292
# Optional sidebars only if the theme ships them
285293
html_sidebars = {

0 commit comments

Comments
 (0)