1- import os , sys
1+ import os
2+ import sys
23from pathlib import Path
34from sphinx .application import Sphinx
45
2526 "sphinxcontrib.bibtex" ,
2627 "sphinx_codeautolink" ,
2728 "notfound.extension" ,
28- "sphinx_gallery.load_style" ,
2929 "thumbnail_extractor" ,
3030 "sphinxext.rediraffe" ,
31- "sphinx_remove_toctrees" ,
3231]
3332
3433# List of patterns, relative to source directory, that match files and
4645]
4746
4847
49- def hack_nbsphinx (app : Sphinx ) -> None :
50- from nbsphinx import (
51- depart_gallery_html ,
52- doctree_resolved ,
53- GalleryNode ,
54- NbGallery ,
55- patched_toctree_resolve ,
56- )
57- from sphinx .environment .adapters import toctree
58-
59- from glob import glob
60-
61- nb_paths = glob ("*/*.ipynb" )
62- nbsphinx_thumbnails = {}
63- for nb_path in nb_paths :
64- png_file = os .path .join (
65- "thumbnails" , os .path .splitext (os .path .split (nb_path )[- 1 ])[0 ] + ".png"
66- )
67- nb_path_rel = os .path .splitext (nb_path )[0 ]
68- nbsphinx_thumbnails [nb_path_rel ] = png_file
69-
70- def builder_inited (app : Sphinx ):
71- if not hasattr (app .env , "nbsphinx_thumbnails" ):
72- app .env .nbsphinx_thumbnails = {}
73-
74- def do_nothing (* node ):
75- pass
76-
77- app .add_config_value ("nbsphinx_thumbnails" , nbsphinx_thumbnails , rebuild = "html" )
78- app .add_directive ("nbgallery" , NbGallery )
79- app .add_node (
80- GalleryNode ,
81- html = (do_nothing , depart_gallery_html ),
82- latex = (do_nothing , do_nothing ),
83- text = (do_nothing , do_nothing ),
84- )
85- app .connect ("builder-inited" , builder_inited )
86- app .connect ("doctree-resolved" , doctree_resolved )
87-
88- # Monkey-patch Sphinx TocTree adapter
89- toctree .TocTree .resolve = patched_toctree_resolve
90-
91-
9248def remove_index (app ):
9349 """
9450 This removes the index pages so rediraffe generates the redirect placeholder
@@ -103,7 +59,6 @@ def remove_index(app):
10359
10460
10561def setup (app : Sphinx ):
106- hack_nbsphinx (app )
10762 app .connect ("html-collect-pages" , remove_index , 100 )
10863
10964
@@ -196,22 +151,6 @@ def setup(app: Sphinx):
196151rediraffe_redirects = {
197152 "index.md" : "gallery.md" ,
198153}
199- remove_from_toctrees = [
200- "BART/*" ,
201- "case_studies/*" ,
202- "causal_inference/*" ,
203- "diagnostics_and_criticism/*" ,
204- "gaussian_processes/*" ,
205- "generalized_linear_models/*" ,
206- "mixture_models/*" ,
207- "ode_models/*" ,
208- "howto/*" ,
209- "samplers/*" ,
210- "splines/*" ,
211- "survival_analysis/*" ,
212- "time_series/*" ,
213- "variational_inference/*" ,
214- ]
215154
216155# bibtex config
217156bibtex_bibfiles = ["references.bib" ]
0 commit comments