Skip to content

Commit c9582f0

Browse files
authored
Merge pull request matplotlib#21890 from QuLogic/pdf-non-retina
Drop retina images when building PDF docs
2 parents 21b76ae + ad9fe72 commit c9582f0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/conf.py

+16
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,21 @@ def _check_dependencies():
167167

168168
# Sphinx gallery configuration
169169

170+
def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
171+
**kwargs):
172+
"""
173+
Reduce srcset when creating a PDF.
174+
175+
Because sphinx-gallery runs *very* early, we cannot modify this even in the
176+
earliest builder-inited signal. Thus we do it at scraping time.
177+
"""
178+
from sphinx_gallery.scrapers import matplotlib_scraper
179+
180+
if gallery_conf['builder_name'] == 'latex':
181+
gallery_conf['image_srcset'] = []
182+
return matplotlib_scraper(block, block_vars, gallery_conf, **kwargs)
183+
184+
170185
sphinx_gallery_conf = {
171186
'examples_dirs': ['../examples', '../tutorials', '../plot_types'],
172187
'filename_pattern': '^((?!sgskip).)*$',
@@ -183,6 +198,7 @@ def _check_dependencies():
183198
'remove_config_comments': True,
184199
'min_reported_time': 1,
185200
'thumbnail_size': (320, 224),
201+
'image_scrapers': (matplotlib_reduced_latex_scraper, ),
186202
# Compression is a significant effort that we skip for local and CI builds.
187203
'compress_images': ('thumbnails', 'images') if is_release_build else (),
188204
'matplotlib_animations': True,

0 commit comments

Comments
 (0)