1
- import os , sys
1
+ import os
2
+ import sys
2
3
from pathlib import Path
3
4
from sphinx .application import Sphinx
4
5
25
26
"sphinxcontrib.bibtex" ,
26
27
"sphinx_codeautolink" ,
27
28
"notfound.extension" ,
28
- "sphinx_gallery.load_style" ,
29
29
"thumbnail_extractor" ,
30
30
"sphinxext.rediraffe" ,
31
- "sphinx_remove_toctrees" ,
32
31
]
33
32
34
33
# List of patterns, relative to source directory, that match files and
46
45
]
47
46
48
47
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
-
92
48
def remove_index (app ):
93
49
"""
94
50
This removes the index pages so rediraffe generates the redirect placeholder
@@ -103,7 +59,6 @@ def remove_index(app):
103
59
104
60
105
61
def setup (app : Sphinx ):
106
- hack_nbsphinx (app )
107
62
app .connect ("html-collect-pages" , remove_index , 100 )
108
63
109
64
@@ -196,22 +151,6 @@ def setup(app: Sphinx):
196
151
rediraffe_redirects = {
197
152
"index.md" : "gallery.md" ,
198
153
}
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
- ]
215
154
216
155
# bibtex config
217
156
bibtex_bibfiles = ["references.bib" ]
0 commit comments