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

Skip to content

Commit a7e006a

Browse files
authored
Merge pull request #8456 from choldgraf/sphinx_gallery
Migration to sphinx-gallery
2 parents 3d75591 + 3f1ba02 commit a7e006a

161 files changed

Lines changed: 235 additions & 313 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
build
3333
# sphinx build directory
3434
doc/_build
35+
doc/gallery
3536
# setup.py dist directory
3637
dist
3738
# Egg metadata
@@ -57,12 +58,13 @@ lib/matplotlib/mpl-data/matplotlibrc
5758

5859
# Documentation generated files #
5960
#################################
61+
doc/api/_as_gen
6062
doc/examples
61-
doc/_templates/gallery.html
63+
# autogenerated by sphinx-gallery
64+
doc/modules
65+
doc/pyplots/tex_demo.png
6266
doc/users/installing.rst
6367
doc/_static/matplotlibrc
64-
doc/pyplots/tex_demo.png
65-
doc/api/_as_gen
6668
lib/dateutil
6769
examples/*/*.pdf
6870
examples/*/*.png

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ install:
142142
pip install -ve .
143143
144144
script: source ci/travis/test_script.sh
145+
145146
before_cache:
146147
- rm -rf $HOME/.cache/matplotlib/tex.cache
147148
- rm -rf $HOME/.cache/matplotlib/test_cache

ci/travis/test_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if [[ $BUILD_DOCS == false ]]; then
3030
fi
3131
else
3232
cd doc
33-
python make.py html -n 2
33+
python make.py html
3434
# We don't build the LaTeX docs here, so linkchecker will complain
3535
touch build/html/Matplotlib.pdf
3636
# Linkchecker only works with python 2.7 for the time being

doc-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ ipython
1212
mock
1313
colorspacious
1414
pillow
15+
sphinx-gallery

doc/README.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ All of these dependencies *except graphviz* can be installed through pip::
2121

2222
or all of them via conda and pip::
2323

24-
conda install sphinx numpydoc ipython mock graphviz pillow
24+
conda install sphinx numpydoc ipython mock graphviz pillow \
25+
sphinx-gallery
2526
pip install colorspacious
2627

2728
To build the HTML documentation, type ``python make.py html`` in this

doc/_templates/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ <h1>Introduction</h1>
7575
<p>Matplotlib tries to make easy things easy and hard things possible.
7676
You can generate plots, histograms, power spectra, bar charts,
7777
errorcharts, scatterplots, etc., with just a few lines of code.
78-
For a sampling, see the <a href="{{ pathto('users/screenshots') }}">screenshots</a>, <a href="{{ pathto('gallery') }}">thumbnail</a> gallery, and
78+
For a sampling, see the <a href="{{ pathto('users/screenshots')
79+
}}">screenshots</a>, <a href="{{ pathto('gallery/index') }}">thumbnail</a> gallery, and
7980
<a href="{{ pathto('examples/index') }}">examples</a> directory</p>
8081

8182
<p>For simple plotting the <tt>pyplot</tt> module provides a
@@ -99,7 +100,7 @@ <h1>Documentation</h1>
99100
</script>
100101

101102
<p>Trying to learn how to do a particular kind of plot? Check out
102-
the <a href="{{ pathto('gallery') }}">gallery</a>, <a href="{{ pathto('examples/index') }}">examples</a>,
103+
the <a href="{{ pathto('gallery/index') }}">gallery</a>, <a href="{{ pathto('examples/index') }}">examples</a>,
103104
or the <a href="{{ pathto('api/pyplot_summary') }}">list of plotting
104105
commands</a>.</p>
105106

doc/_templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h3>{{ _('Navigation') }}</h3>
3939

4040
<li><a href="{{ pathto('index') }}">home</a>|&nbsp;</li>
4141
<li><a href="{{ pathto('examples/index') }}">examples</a>|&nbsp;</li>
42-
<li><a href="{{ pathto('gallery') }}">gallery</a>|&nbsp;</li>
42+
<li><a href="{{ pathto('gallery/index') }}">gallery</a>|&nbsp;</li>
4343
<li><a href="{{ pathto('api/pyplot_summary') }}">pyplot</a>|&nbsp;</li>
4444
<li><a href="{{ pathto('contents') }}">docs</a> &raquo;</li>
4545

doc/conf.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
extensions = ['matplotlib.sphinxext.mathmpl', 'sphinxext.math_symbol_table',
3030
'sphinx.ext.autodoc', 'matplotlib.sphinxext.only_directives',
3131
'sphinx.ext.doctest', 'sphinx.ext.autosummary',
32-
'matplotlib.sphinxext.plot_directive',
3332
'sphinx.ext.inheritance_diagram',
34-
'sphinxext.gen_gallery', 'sphinxext.gen_rst',
33+
'sphinx_gallery.gen_gallery',
34+
'sphinxext.gen_rst',
35+
'matplotlib.sphinxext.plot_directive',
3536
'sphinxext.github',
3637
'numpydoc']
3738

@@ -53,6 +54,12 @@
5354
raise ImportError("No module named numpydoc - you need to install "
5455
"numpydoc to build the documentation.")
5556

57+
try:
58+
import sphinx_gallery
59+
except ImportError:
60+
raise ImportError("No module named sphinx_gallery - you need to install "
61+
"sphinx_gallery to build the documentation.")
62+
5663
try:
5764
import colorspacious
5865
except ImportError:
@@ -96,6 +103,15 @@
96103

97104
autodoc_docstring_signature = True
98105

106+
107+
# Sphinx gallery configuration
108+
sphinx_gallery_conf = {
109+
'examples_dirs': '../examples',
110+
'filename_pattern': '\.py$',
111+
'gallery_dirs': 'gallery'}
112+
113+
plot_gallery = True
114+
99115
# Add any paths that contain templates here, relative to this directory.
100116
templates_path = ['_templates']
101117

@@ -234,7 +250,6 @@
234250
# Additional templates that should be rendered to pages, maps page names to
235251
# template names.
236252
html_additional_pages = {'index': 'index.html',
237-
'gallery':'gallery.html',
238253
'citing': 'citing.html'}
239254

240255
# If false, no module index is generated.

doc/devel/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ We have hundreds of examples in subdirectories of
442442
:file:`matplotlib/examples`, and these are automatically generated
443443
when the website is built to show up both in the `examples
444444
<../examples/index.html>`_ and `gallery
445-
<../gallery.html>`_ sections of the website.
445+
<../gallery/index.html>`_ sections of the website.
446446

447447
Any sample data that the example uses should be kept small and
448448
distributed with Matplotlib in the

doc/faq/howto_faq.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ some ratio which controls the ratio::
353353

354354
.. htmlonly::
355355

356-
See :ref:`subplots_axes_and_figures-plot_equal_aspect_ratio` for a complete
356+
See :ref:`subplots_axes_and_figures-equal_aspect_ratio` for a complete
357357
example.
358358

359359

@@ -398,7 +398,7 @@ locators as desired because the two axes are independent.
398398

399399
.. htmlonly::
400400

401-
See :ref:`api-plot_two_scales` for a complete example
401+
See :ref:`api-two_scales` for a complete example
402402

403403
.. _howto-batch:
404404

@@ -644,7 +644,7 @@ For more on configuring your backend, see
644644

645645
Alternatively, you can avoid pylab/pyplot altogether, which will give
646646
you a little more control, by calling the API directly as shown in
647-
:ref:`api-plot_agg_oo`.
647+
:ref:`api-agg_oo`.
648648

649649
You can either generate hardcopy on the filesystem by calling savefig::
650650

0 commit comments

Comments
 (0)