Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29e77e3

Browse files
ksundenmeeseeksmachine
authored andcommitted
Backport PR#28103: [DOC]: Fix compatibility with sphinx-gallery 0.16
1 parent26979f7 commit29e77e3

File tree

5 files changed

+48
-35
lines changed

5 files changed

+48
-35
lines changed

‎doc/conf.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
fromurllib.parseimporturlsplit,urlunsplit
2323
importwarnings
2424

25+
frompackaging.versionimportparseasparse_version
2526
importsphinx
2627
importyaml
2728

@@ -178,9 +179,20 @@ def _check_dependencies():
178179

179180

180181
# Import only after checking for dependencies.
181-
# gallery_order.py from the sphinxext folder provides the classes that
182-
# allow custom ordering of sections and subsections of the gallery
183-
importsphinxext.gallery_orderasgallery_order
182+
importsphinx_gallery
183+
184+
ifparse_version(sphinx_gallery.__version__)>=parse_version('0.16.0'):
185+
gallery_order_sectionorder='sphinxext.gallery_order.sectionorder'
186+
gallery_order_subsectionorder='sphinxext.gallery_order.subsectionorder'
187+
clear_basic_units='sphinxext.util.clear_basic_units'
188+
matplotlib_reduced_latex_scraper='sphinxext.util.matplotlib_reduced_latex_scraper'
189+
else:
190+
# gallery_order.py from the sphinxext folder provides the classes that
191+
# allow custom ordering of sections and subsections of the gallery
192+
fromsphinxext.gallery_orderimport (
193+
sectionorderasgallery_order_sectionorder,
194+
subsectionorderasgallery_order_subsectionorder)
195+
fromsphinxext.utilimportclear_basic_units,matplotlib_reduced_latex_scraper
184196

185197
# The following import is only necessary to monkey patch the signature later on
186198
fromsphinx_galleryimportgen_rst
@@ -228,22 +240,6 @@ def _check_dependencies():
228240
}
229241

230242

231-
# Sphinx gallery configuration
232-
233-
defmatplotlib_reduced_latex_scraper(block,block_vars,gallery_conf,
234-
**kwargs):
235-
"""
236-
Reduce srcset when creating a PDF.
237-
238-
Because sphinx-gallery runs *very* early, we cannot modify this even in the
239-
earliest builder-inited signal. Thus we do it at scraping time.
240-
"""
241-
fromsphinx_gallery.scrapersimportmatplotlib_scraper
242-
243-
ifgallery_conf['builder_name']=='latex':
244-
gallery_conf['image_srcset']= []
245-
returnmatplotlib_scraper(block,block_vars,gallery_conf,**kwargs)
246-
247243
gallery_dirs= [f'{ed}'foredin
248244
['gallery','tutorials','plot_types','users/explain']
249245
iff'{ed}/*'notinskip_subdirs]
@@ -254,7 +250,7 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
254250
example_dirs+= [f'../galleries/{gd}']
255251

256252
sphinx_gallery_conf= {
257-
'backreferences_dir':Path('api')/Path('_as_gen'),
253+
'backreferences_dir':Path('api','_as_gen'),
258254
# Compression is a significant effort that we skip for local and CI builds.
259255
'compress_images': ('thumbnails','images')ifis_release_buildelse (),
260256
'doc_module': ('matplotlib','mpl_toolkits'),
@@ -269,14 +265,10 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
269265
'plot_gallery':'True',# sphinx-gallery/913
270266
'reference_url': {'matplotlib':None},
271267
'remove_config_comments':True,
272-
'reset_modules': (
273-
'matplotlib',
274-
# clear basic_units module to re-register with unit registry on import
275-
lambdagallery_conf,fname:sys.modules.pop('basic_units',None)
276-
),
277-
'subsection_order':gallery_order.sectionorder,
268+
'reset_modules': ('matplotlib',clear_basic_units),
269+
'subsection_order':gallery_order_sectionorder,
278270
'thumbnail_size': (320,224),
279-
'within_subsection_order':gallery_order.subsectionorder,
271+
'within_subsection_order':gallery_order_subsectionorder,
280272
'capture_repr': (),
281273
'copyfile_regex':r'.*\.rst',
282274
}
@@ -333,7 +325,7 @@ def gallery_image_warning_filter(record):
333325
:class: sphx-glr-download-link-note
334326
335327
:ref:`Go to the end <sphx_glr_download_{1}>`
336-
to download the full example code{2}
328+
to download the full example code.{2}
337329
338330
.. rst-class:: sphx-glr-example-title
339331
@@ -758,7 +750,6 @@ def js_tag_with_cache_busting(js):
758750

759751
iflink_github:
760752
importinspect
761-
frompackaging.versionimportparse
762753

763754
extensions.append('sphinx.ext.linkcode')
764755

@@ -814,7 +805,7 @@ def linkcode_resolve(domain, info):
814805
ifnotfn.startswith(('matplotlib/','mpl_toolkits/')):
815806
returnNone
816807

817-
version=parse(matplotlib.__version__)
808+
version=parse_version(matplotlib.__version__)
818809
tag='main'ifversion.is_devreleaseelsef'v{version.public}'
819810
return ("https://github.com/matplotlib/matplotlib/blob"
820811
f"/{tag}/lib/{fn}{linespec}")

‎doc/sphinxext/gallery_order.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __call__(self, item):
105105
explicit_subsection_order= [item+".py"foriteminlist_all]
106106

107107

108-
classMplExplicitSubOrder:
108+
classMplExplicitSubOrder(ExplicitOrder):
109109
"""For use within the 'within_subsection_order' key."""
110110
def__init__(self,src_dir):
111111
self.src_dir=src_dir# src_dir is unused here

‎doc/sphinxext/util.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
importsys
2+
3+
4+
defmatplotlib_reduced_latex_scraper(block,block_vars,gallery_conf,
5+
**kwargs):
6+
"""
7+
Reduce srcset when creating a PDF.
8+
9+
Because sphinx-gallery runs *very* early, we cannot modify this even in the
10+
earliest builder-inited signal. Thus we do it at scraping time.
11+
"""
12+
fromsphinx_gallery.scrapersimportmatplotlib_scraper
13+
14+
ifgallery_conf['builder_name']=='latex':
15+
gallery_conf['image_srcset']= []
16+
returnmatplotlib_scraper(block,block_vars,gallery_conf,**kwargs)
17+
18+
19+
# Clear basic_units module to re-register with unit registry on import.
20+
defclear_basic_units(gallery_conf,fname):
21+
returnsys.modules.pop('basic_units',None)

‎lib/matplotlib/tests/test_doc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def test_sphinx_gallery_example_header():
99
EXAMPLE_HEADER, this test will start to fail. In that case, please update
1010
the monkey-patching of EXAMPLE_HEADER in conf.py.
1111
"""
12-
gen_rst=pytest.importorskip('sphinx_gallery.gen_rst')
12+
pytest.importorskip('sphinx_gallery',minversion='0.16.0')
13+
fromsphinx_galleryimportgen_rst
1314

1415
EXAMPLE_HEADER="""
1516
.. DO NOT EDIT.
@@ -24,7 +25,7 @@ def test_sphinx_gallery_example_header():
2425
:class: sphx-glr-download-link-note
2526
2627
:ref:`Go to the end <sphx_glr_download_{1}>`
27-
to download the full example code{2}
28+
to download the full example code.{2}
2829
2930
.. rst-class:: sphx-glr-example-title
3031

‎requirements/doc/doc-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Install the documentation requirements with:
88
# pip install -r requirements/doc/doc-requirements.txt
99
#
10-
sphinx>=3.0.0,!=6.1.2,!=7.3.*
10+
sphinx>=3.0.0,!=6.1.2
1111
colorspacious
1212
ipython
1313
ipywidgets
@@ -18,7 +18,7 @@ pydata-sphinx-theme~=0.15.0
1818
mpl-sphinx-theme~=3.8.0
1919
pyyaml
2020
sphinxcontrib-svg2pdfconverter>=1.1.0
21-
sphinx-gallery>=0.12.0
2221
sphinx-copybutton
2322
sphinx-design
23+
sphinx-gallery>=0.12.0
2424
sphinx-tags>=0.3.0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp