Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86ce2d6

Browse files
committed
sphinx-exhibit testing ground.
1 parent 72088e5 commit 86ce2d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+283
-162
lines changed

.gitignore

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,22 @@ lib/matplotlib/mpl-data/matplotlibrc
6060
# sphinx build directory
6161
doc/_build
6262
doc/api/_as_gen
63-
# autogenerated by sphinx-gallery
64-
doc/examples
65-
doc/gallery
66-
doc/tutorials
63+
# autogenerated by sphinx-exhibit
64+
doc/gallery/*
65+
!doc/gallery/index.rst
66+
doc/tutorials/*
67+
!doc/tutorials/index.rst
6768
doc/modules
6869
doc/pyplots/tex_demo.png
6970
lib/dateutil
7071
examples/*/*.pdf
7172
examples/*/*.png
7273
examples/*/*.svg
73-
examples/*/*.eps
7474
examples/*/*.svgz
75+
examples/*/*.eps
76+
examples/*/*.mp4
7577
examples/tests/*
76-
!examples/tests/backend_driver.py
78+
!examples/tests/backend_driver_sgskip.py
7779
result_images
7880

7981
# Nose/Pytest generated files #

doc-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ ipywidgets
1313
numpydoc>=0.4
1414
pillow
1515
sphinx-gallery>=0.1.13
16+
git+https://github.com/anntzer/sphinx-exhibit
17+
git+https://github.com/anntzer/sphinx-jinja

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33

44
# You can set these variables from the command line.
5-
SPHINXOPTS = -W
5+
SPHINXOPTS =
66
SPHINXBUILD = python -msphinx
77
SPHINXPROJ = matplotlib
88
SOURCEDIR = .

doc/_templates/autosummary.rst

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
1-
{{ fullname | escape | underline}}
2-
1+
{{ fullname | escape | underline }}
32

43
.. currentmodule:: {{ module }}
54

6-
75
{% if objtype in ['class'] %}
86
.. auto{{ objtype }}:: {{ objname }}
9-
:show-inheritance:
10-
7+
:show-inheritance:
118
{% else %}
129
.. auto{{ objtype }}:: {{ objname }}
13-
14-
{% endif %}
15-
16-
{% if objtype in ['class', 'method', 'function'] %}
17-
{% if objname in ['AxesGrid', 'Scalable', 'HostAxes', 'FloatingAxes',
18-
'ParasiteAxesAuxTrans', 'ParasiteAxes'] %}
19-
.. Filter out the above aliases to other classes, as sphinx gallery
20-
creates no example file for those (sphinx-gallery/sphinx-gallery#365)
21-
22-
{% else %}
23-
.. include:: {{module}}.{{objname}}.examples
24-
25-
.. raw:: html
26-
27-
<div class="clearer"></div>
28-
2910
{% endif %}
30-
{% endif %}

doc/_templates/function.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
.. autofunction:: {{ objname }}
77

8-
.. include:: {{module}}.{{objname}}.examples
9-
108
.. raw:: html
119

12-
<div class="clearer"></div>
10+
<div class="clearer"></div>

doc/conf.py

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
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-
7974
if 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.
12893
templates_path = ['_templates']
12994

@@ -329,3 +294,46 @@ def _check_deps():
329294
# numpydoc config
330295

331296
numpydoc_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)

doc/contents.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
Overview
42
========
53

@@ -10,7 +8,6 @@ Overview
108

119
Download `PDF <Matplotlib.pdf>`_
1210

13-
1411
.. toctree::
1512
:maxdepth: 2
1613

@@ -22,6 +19,12 @@ Overview
2219
devel/index.rst
2320
glossary/index.rst
2421

22+
.. toctree::
23+
:hidden:
24+
25+
gallery/index
26+
tutorials/index
27+
2528
.. only:: html
2629

2730
* :ref:`genindex`

doc/gallery/index.rst

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
.. include:: ../../examples/README.txt
2+
3+
.. include:: ../../examples/lines_bars_and_markers/README.txt
4+
5+
.. exhibit::
6+
:srcdir: ../../examples
7+
8+
lines_bars_and_markers/*.py
9+
10+
.. include:: ../../examples/images_contours_and_fields/README.txt
11+
12+
.. exhibit::
13+
:srcdir: ../../examples
14+
15+
images_contours_and_fields/*.py
16+
17+
.. include:: ../../examples/subplots_axes_and_figures/README.txt
18+
19+
.. exhibit::
20+
:srcdir: ../../examples
21+
22+
subplots_axes_and_figures/*.py
23+
24+
.. include:: ../../examples/statistics/README.txt
25+
26+
.. exhibit::
27+
:srcdir: ../../examples
28+
29+
statistics/*.py
30+
31+
.. include:: ../../examples/pie_and_polar_charts/README.txt
32+
33+
.. exhibit::
34+
:srcdir: ../../examples
35+
36+
pie_features.py
37+
pie_demo2.py
38+
pie_and_polar_charts/*.py
39+
40+
.. include:: ../../examples/text_labels_and_annotations/README.txt
41+
42+
.. exhibit::
43+
:srcdir: ../../examples
44+
45+
text_labels_and_annotations/*.py
46+
47+
.. include:: ../../examples/pyplots/README.txt
48+
49+
.. exhibit::
50+
:srcdir: ../../examples
51+
52+
pyplots/*.py
53+
54+
.. include:: ../../examples/color/README.txt
55+
56+
.. exhibit::
57+
:srcdir: ../../examples
58+
59+
color/color_demo.py
60+
color/*.py
61+
62+
.. include:: ../../examples/shapes_and_collections/README.txt
63+
64+
.. exhibit::
65+
:srcdir: ../../examples
66+
67+
shapes_and_collections/*.py
68+
69+
.. include:: ../../examples/style_sheets/README.txt
70+
71+
.. exhibit::
72+
:srcdir: ../../examples
73+
74+
style_sheets/*.py
75+
76+
.. include:: ../../examples/axes_grid1/README.txt
77+
78+
.. exhibit::
79+
:srcdir: ../../examples
80+
81+
axes_grid1/*.py
82+
83+
.. include:: ../../examples/axisartist/README.txt
84+
85+
.. exhibit::
86+
:srcdir: ../../examples
87+
88+
axisartist/*.py
89+
90+
.. include:: ../../examples/showcase/README.txt
91+
92+
.. exhibit::
93+
:srcdir: ../../examples
94+
95+
showcase/*.py
96+
97+
.. jinja:: default
98+
99+
{% for subdir in examples %}
100+
.. include:: ../../examples/{{ subdir }}/README.txt
101+
102+
.. exhibit::
103+
:srcdir: ../../examples
104+
105+
{{ subdir }}/*.py
106+
{% endfor %}

0 commit comments

Comments
 (0)