Skip to content

Commit 9d0781d

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR matplotlib#30858: DOC: reinstate "codex" search term
1 parent 1957ba3 commit 9d0781d

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

doc/conf.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ def _check_dependencies():
200200
else:
201201
sg_matplotlib_animations = True
202202

203-
# The following import is only necessary to monkey patch the signature later on
204-
from sphinx_gallery import gen_rst
205203

206204
# Prevent plt.show() from emitting a non-GUI backend warning.
207205
warnings.filterwarnings('ignore', category=UserWarning,
@@ -299,7 +297,7 @@ def autodoc_process_bases(app, name, obj, options, bases):
299297
'reference_url': {'matplotlib': None, 'mpl_toolkits': None},
300298
'prefer_full_module': {r'mpl_toolkits\.'},
301299
'remove_config_comments': True,
302-
'reset_modules': ('matplotlib', clear_basic_units),
300+
'reset_modules': ('matplotlib', clear_basic_units, 'sphinxext.util.patch_header'),
303301
'subsection_order': gallery_order_sectionorder,
304302
'thumbnail_size': (320, 224),
305303
'within_subsection_order': gallery_order_subsectionorder,
@@ -347,31 +345,6 @@ def gallery_image_warning_filter(record):
347345
mathmpl_fontsize = 11.0
348346
mathmpl_srcset = ['2x']
349347

350-
# Monkey-patching gallery header to include search keywords
351-
gen_rst.EXAMPLE_HEADER = """
352-
.. DO NOT EDIT.
353-
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
354-
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
355-
.. "{0}"
356-
.. LINE NUMBERS ARE GIVEN BELOW.
357-
358-
.. only:: html
359-
360-
.. meta::
361-
:keywords: codex
362-
363-
.. note::
364-
:class: sphx-glr-download-link-note
365-
366-
:ref:`Go to the end <sphx_glr_download_{1}>`
367-
to download the full example code{2}
368-
369-
.. rst-class:: sphx-glr-example-title
370-
371-
.. _sphx_glr_{1}:
372-
373-
"""
374-
375348
# Add any paths that contain templates here, relative to this directory.
376349
templates_path = ['_templates']
377350

doc/sphinxext/util.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import sys
22

3+
from sphinx_gallery import gen_rst
4+
35

46
def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
57
**kwargs):
@@ -19,3 +21,33 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
1921
# Clear basic_units module to re-register with unit registry on import.
2022
def clear_basic_units(gallery_conf, fname):
2123
return sys.modules.pop('basic_units', None)
24+
25+
26+
# Monkey-patching gallery header to include search keywords
27+
EXAMPLE_HEADER = """
28+
.. DO NOT EDIT.
29+
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
30+
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
31+
.. "{0}"
32+
.. LINE NUMBERS ARE GIVEN BELOW.
33+
34+
.. only:: html
35+
36+
.. meta::
37+
:keywords: codex
38+
39+
.. note::
40+
:class: sphx-glr-download-link-note
41+
42+
:ref:`Go to the end <sphx_glr_download_{1}>`
43+
to download the full example code{2}
44+
45+
.. rst-class:: sphx-glr-example-title
46+
47+
.. _sphx_glr_{1}:
48+
49+
"""
50+
51+
52+
def patch_header(gallery_conf, fname):
53+
gen_rst.EXAMPLE_HEADER = EXAMPLE_HEADER

lib/matplotlib/tests/test_doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def test_sphinx_gallery_example_header():
77
This test monitors that the version we have copied is still the same as
88
the EXAMPLE_HEADER in sphinx-gallery. If sphinx-gallery changes its
99
EXAMPLE_HEADER, this test will start to fail. In that case, please update
10-
the monkey-patching of EXAMPLE_HEADER in conf.py.
10+
the monkey-patching of EXAMPLE_HEADER in sphinxext/util.py.
1111
"""
1212
pytest.importorskip('sphinx_gallery', minversion='0.20.0')
1313
from sphinx_gallery import gen_rst

0 commit comments

Comments
 (0)