3636 'IPython.sphinxext.ipython_console_highlighting' ,
3737 'IPython.sphinxext.ipython_directive' ,
3838 'numpydoc' , # Needs to be loaded *after* autodoc.
39- 'sphinx_gallery.gen_gallery' ,
39+ 'sphinx_exhibit' ,
40+ 'sphinxcontrib.jinja' ,
4041 'matplotlib.sphinxext.mathmpl' ,
4142 'matplotlib.sphinxext.plot_directive' ,
4243 'sphinxext.custom_roles' ,
@@ -55,6 +56,7 @@ def _check_deps():
5556 "matplotlib" : 'matplotlib' ,
5657 "numpydoc" : 'numpydoc' ,
5758 "PIL.Image" : 'pillow' ,
59+ "sphinx_exhibit" : 'sphinx_exhibit' ,
5860 "sphinx_gallery" : 'sphinx_gallery' }
5961 missing = []
6062 for name in names :
@@ -69,13 +71,6 @@ def _check_deps():
6971
7072_check_deps ()
7173
72- # Import only after checking for dependencies.
73- # gallery_order.py from the sphinxext folder provides the classes that
74- # allow custom ordering of sections and subsections of the gallery
75- import sphinxext .gallery_order as gallery_order
76- # The following import is only necessary to monkey patch the signature later on
77- from sphinx_gallery import gen_rst
78-
7974if shutil .which ('dot' ) is None :
8075 raise OSError (
8176 "No binary named dot - you need to install the Graph Visualization "
@@ -94,36 +89,6 @@ def _check_deps():
9489 'cycler' : ('https://matplotlib.org/cycler' , None ),
9590}
9691
97-
98- # Sphinx gallery configuration
99- sphinx_gallery_conf = {
100- 'examples_dirs' : ['../examples' , '../tutorials' ],
101- 'filename_pattern' : '^((?!sgskip).)*$' ,
102- 'gallery_dirs' : ['gallery' , 'tutorials' ],
103- 'doc_module' : ('matplotlib' , 'mpl_toolkits' ),
104- 'reference_url' : {
105- 'matplotlib' : None ,
106- 'numpy' : 'https://docs.scipy.org/doc/numpy' ,
107- 'scipy' : 'https://docs.scipy.org/doc/scipy/reference' ,
108- },
109- 'backreferences_dir' : 'api/_as_gen' ,
110- 'subsection_order' : gallery_order .sectionorder ,
111- 'within_subsection_order' : gallery_order .subsectionorder ,
112- 'min_reported_time' : 1 ,
113- }
114-
115- plot_gallery = 'True'
116-
117- # Monkey-patching gallery signature to include search keywords
118- gen_rst .SPHX_GLR_SIG = """\n
119- .. only:: html
120-
121- .. rst-class:: sphx-glr-signature
122-
123- Keywords: matplotlib code example, codex, python plot, pyplot
124- `Gallery generated by Sphinx-Gallery
125- <https://sphinx-gallery.readthedocs.io>`_\n """
126-
12792# Add any paths that contain templates here, relative to this directory.
12893templates_path = ['_templates' ]
12994
@@ -329,3 +294,46 @@ def _check_deps():
329294# numpydoc config
330295
331296numpydoc_show_class_members = False
297+
298+ # Other configs.
299+
300+ from pathlib import Path
301+ jinja_contexts = {
302+ "default" : {
303+ "examples" : sorted (
304+ dirpath .name
305+ for dirpath in (Path (__file__ ).parent / "../examples" ).iterdir ()
306+ if (dirpath / "README.txt" ).exists () and dirpath .name not in [
307+ "lines_bars_and_markers" ,
308+ "images_contours_and_fields" ,
309+ "subplots_axes_and_figures" ,
310+ "statistics" ,
311+ "pie_and_polar_charts" ,
312+ "text_labels_and_annotations" ,
313+ "pyplots" ,
314+ "color" ,
315+ "shapes_and_collections" ,
316+ "style_sheets" ,
317+ "axes_grid1" ,
318+ "axisartist" ,
319+ "showcase" ,
320+ ]
321+ )
322+ },
323+ }
324+
325+ exhibit_syntax_style = "sphinx-gallery"
326+ exhibit_output_style = "sphinx-gallery"
327+
328+
329+ def autodoc_process_docstring (app , what , name , obj , options , lines ):
330+ lines .extend ([
331+ "" ,
332+ ".. exhibit-backrefs:: py:{} {}" .format (what , name ),
333+ " :title: The following examples showcase the use of :py:obj:`{}`:"
334+ .format (name )])
335+
336+
337+ def setup (app ):
338+ app .setup_extension ("sphinx.ext.autodoc" )
339+ app .connect ("autodoc-process-docstring" , autodoc_process_docstring )
0 commit comments