@@ -537,16 +537,7 @@ def clear_state(plot_rcparams, close=True):
537
537
matplotlib .rcParams .update (plot_rcparams )
538
538
539
539
540
- def render_figures (code , code_path , output_dir , output_base , context ,
541
- function_name , config , context_reset = False ,
542
- close_figs = False ):
543
- """
544
- Run a pyplot script and save the images in *output_dir*.
545
-
546
- Save the images under *output_dir* with file names derived from
547
- *output_base*
548
- """
549
- # -- Parse format list
540
+ def get_plot_formats (config ):
550
541
default_dpi = {'png' : 80 , 'hires.png' : 200 , 'pdf' : 200 }
551
542
formats = []
552
543
plot_formats = config .plot_formats
@@ -562,10 +553,23 @@ def render_figures(code, code_path, output_dir, output_base, context,
562
553
formats .append ((str (suffix ), int (dpi )))
563
554
else :
564
555
formats .append ((fmt , default_dpi .get (fmt , 80 )))
565
- elif type (fmt ) in (tuple , list ) and len (fmt )== 2 :
556
+ elif type (fmt ) in (tuple , list ) and len (fmt ) == 2 :
566
557
formats .append ((str (fmt [0 ]), int (fmt [1 ])))
567
558
else :
568
559
raise PlotError ('invalid image format "%r" in plot_formats' % fmt )
560
+ return formats
561
+
562
+
563
+ def render_figures (code , code_path , output_dir , output_base , context ,
564
+ function_name , config , context_reset = False ,
565
+ close_figs = False ):
566
+ """
567
+ Run a pyplot script and save the images in *output_dir*.
568
+
569
+ Save the images under *output_dir* with file names derived from
570
+ *output_base*
571
+ """
572
+ formats = get_plot_formats (config )
569
573
570
574
# -- Try to determine if all images already exist
571
575
@@ -665,13 +669,8 @@ def run(arguments, content, options, state_machine, state, lineno):
665
669
config = document .settings .env .config
666
670
nofigs = 'nofigs' in options
667
671
668
- plot_formats = config .plot_formats
669
- if isinstance (plot_formats , six .string_types ):
670
- # String Sphinx < 1.3, Split on , to mimic
671
- # Sphinx 1.3 and later. Sphinx 1.3 always
672
- # returns a list.
673
- plot_formats = plot_formats .split (',' )
674
- default_fmt = plot_formats [0 ][0 ]
672
+ formats = get_plot_formats (config )
673
+ default_fmt = formats [0 ][0 ]
675
674
676
675
options .setdefault ('include-source' , config .plot_include_source )
677
676
keep_context = 'context' in options
0 commit comments