@@ -278,7 +278,16 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
278
278
# Plot directive configuration
279
279
# ----------------------------
280
280
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
+
282
291
283
292
# GitHub extension
284
293
@@ -537,30 +546,13 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
537
546
# graphviz_output_format = 'svg'
538
547
539
548
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
-
554
549
def setup (app ):
555
550
if any (st in version for st in ('post' , 'alpha' , 'beta' )):
556
551
bld_type = 'dev'
557
552
else :
558
553
bld_type = 'rel'
559
554
app .add_config_value ('releaselevel' , bld_type , 'env' )
560
555
561
- if not is_release_build :
562
- app .connect ('builder-inited' , reduce_plot_formats )
563
-
564
556
# -----------------------------------------------------------------------------
565
557
# Source code links
566
558
# -----------------------------------------------------------------------------
0 commit comments