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

Appearance settings

Commit c47f770

Browse filesBrowse files
authored
Merge pull request #22685 from timhoffm/sphinx-plot_formats
Rewrite plot format detection from sphinx build target
2 parents a65efef + 348b913 commit c47f770
Copy full SHA for c47f770

File tree

Expand file treeCollapse file tree

1 file changed

+10
-18
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-18
lines changed

‎doc/conf.py

Copy file name to clipboardExpand all lines: doc/conf.py
+10-18Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,16 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
278278
# Plot directive configuration
279279
# ----------------------------
280280

281-
plot_formats = [('png', 100), ('pdf', 100)]
281+
# For speedup, decide which plot_formats to build based on build targets:
282+
# html only -> png
283+
# latex only -> pdf
284+
# all other cases, including html + latex -> png, pdf
285+
# For simplicity, we assume that the build targets appear in the command line.
286+
# We're falling back on using all formats in case that assumption fails.
287+
formats = {'html': ('png', 100), 'latex': ('pdf', 100)}
288+
plot_formats = [formats[target] for target in ['html', 'latex']
289+
if target in sys.argv] or list(formats.values())
290+
282291

283292
# GitHub extension
284293

@@ -537,30 +546,13 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
537546
# graphviz_output_format = 'svg'
538547

539548

540-
def reduce_plot_formats(app):
541-
# Fox CI and local builds, we don't need all the default plot formats, so
542-
# only generate the directly useful one for the current builder.
543-
if app.builder.name == 'html':
544-
keep = 'png'
545-
elif app.builder.name == 'latex':
546-
keep = 'pdf'
547-
else:
548-
return
549-
app.config.plot_formats = [entry
550-
for entry in app.config.plot_formats
551-
if entry[0] == keep]
552-
553-
554549
def setup(app):
555550
if any(st in version for st in ('post', 'alpha', 'beta')):
556551
bld_type = 'dev'
557552
else:
558553
bld_type = 'rel'
559554
app.add_config_value('releaselevel', bld_type, 'env')
560555

561-
if not is_release_build:
562-
app.connect('builder-inited', reduce_plot_formats)
563-
564556
# -----------------------------------------------------------------------------
565557
# Source code links
566558
# -----------------------------------------------------------------------------

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.