8000 Drop retina images when building PDF docs by QuLogic · Pull Request #21890 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Drop retina images when building PDF docs #21890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ def _check_dependencies():

# Sphinx gallery configuration

def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
**kwargs):
"""
Reduce srcset when creating a PDF.

Because sphinx-gallery runs *very* early, we cannot modify this even in the
earliest builder-inited signal. Thus we do it at scraping time.
"""
from sphinx_gallery.scrapers import matplotlib_scraper

if gallery_conf['builder_name'] == 'latex':
gallery_conf['image_srcset'] = []
return matplotlib_scraper(block, block_vars, gallery_conf, **kwargs)


sphinx_gallery_conf = {
'examples_dirs': ['../examples', '../tutorials', '../plot_types'],
'filename_pattern': '^((?!sgskip).)*$',
Expand All @@ -183,6 +198,7 @@ def _check_dependencies():
'remove_config_comments': True,
'min_reported_time': 1,
'thumbnail_size': (320, 224),
'image_scrapers': (matplotlib_reduced_latex_scraper, ),
# Compression is a significant effort that we skip for local and CI builds.
'compress_images': ('thumbnails', 'images') if is_release_build else (),
'matplotlib_animations': True,
Expand Down
0