File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1414 # nodejs: "16"
1515 # rust: "1.55"
1616 # golang: "1.17"
17- commands :
18- # Generate gallery before building docs
19- - python scripts/generate_gallery.py
2017
2118# Build documentation in the docs/ directory with Sphinx
2219sphinx :
Original file line number Diff line number Diff line change 1111
1212import os
1313import sys
14+ from pathlib import Path
1415
1516from causalpy .version import __version__
1617
1718sys .path .insert (0 , os .path .abspath ("../" ))
1819
20+
21+ # Generate gallery before building docs
22+ # This runs after dependencies are installed but before Sphinx processes files
23+ def generate_gallery ():
24+ """Generate example gallery from notebooks."""
25+ try :
26+ # Import here to avoid errors if dependencies aren't available
27+ import subprocess
28+
29+ repo_root = Path (__file__ ).parent .parent .parent
30+ script_path = repo_root / "scripts" / "generate_gallery.py"
31+
32+ if script_path .exists ():
33+ result = subprocess .run (
34+ [sys .executable , str (script_path )],
35+ cwd = str (repo_root ),
36+ capture_output = True ,
37+ text = True ,
38+ )
39+ if result .returncode != 0 :
40+ print (f"Warning: Gallery generation failed: { result .stderr } " )
41+ except Exception as e :
42+ print (f"Warning: Could not generate gallery: { e } " )
43+
44+
45+ # Generate gallery during Sphinx setup
46+ generate_gallery ()
47+
1948# autodoc_mock_imports
2049# This avoids autodoc breaking when it can't find packages imported in the code.
2150# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_mock_imports # noqa: E501
You can’t perform that action at this time.
0 commit comments