|
50 | 50 | ``:output-base-name:`` : str
|
51 | 51 | The base name (without the extension) of the outputted image files. The
|
52 | 52 | default is to use the same name as the input script, or the name of
|
53 |
| - the RST document if no script is provided. The string can include the |
54 |
| - format ``{counter}`` to use an incremented counter. For example, |
55 |
| - ``'plot-{counter}'`` will create files like ``plot-1.png``, ``plot-2.png``, |
56 |
| - and so on. If the ``{counter}`` is not provided, two plots with the same |
| 53 | + the RST document if no script is provided. Note: two plots with the same |
57 | 54 | output-base-name may overwrite each other.
|
58 | 55 |
|
59 | 56 | ``:format:`` : {'python', 'doctest'}
|
|
97 | 94 |
|
98 | 95 | The plot directive has the following configuration options:
|
99 | 96 |
|
100 |
| -plot_output_base_name |
101 |
| - Default value for the output-base-name option (default is to use the name |
102 |
| - of the input script, or the name of the RST file if no script is provided) |
103 |
| -
|
104 | 97 | plot_include_source
|
105 | 98 | Default value for the include-source option (default: False).
|
106 | 99 |
|
@@ -313,7 +306,6 @@ def setup(app):
|
313 | 306 | app.add_config_value('plot_pre_code', None, True)
|
314 | 307 | app.add_config_value('plot_include_source', False, True)
|
315 | 308 | app.add_config_value('plot_html_show_source_link', True, True)
|
316 |
| - app.add_config_value('plot_output_base_name', None, True) |
317 | 309 | app.add_config_value('plot_formats', ['png', 'hires.png', 'pdf'], True)
|
318 | 310 | app.add_config_value('plot_basedir', None, True)
|
319 | 311 | app.add_config_value('plot_html_show_formats', True, True)
|
@@ -749,7 +741,7 @@ def run(arguments, content, options, state_machine, state, lineno):
|
749 | 741 |
|
750 | 742 | options.setdefault('include-source', config.plot_include_source)
|
751 | 743 | options.setdefault('show-source-link', config.plot_html_show_source_link)
|
752 |
| - options.setdefault('output-base-name', config.plot_output_base_name) |
| 744 | + options.setdefault('output-base-name', None) |
753 | 745 |
|
754 | 746 | if 'class' in options:
|
755 | 747 | # classes are parsed into a list of string, and output by simply
|
@@ -798,12 +790,12 @@ def run(arguments, content, options, state_machine, state, lineno):
|
798 | 790 | else:
|
799 | 791 | source_file_name = rst_file
|
800 | 792 | code = textwrap.dedent("\n".join(map(str, content)))
|
801 |
| - counter = document.attributes.get('_plot_counter', 0) + 1 |
802 |
| - document.attributes['_plot_counter'] = counter |
803 | 793 | base, ext = os.path.splitext(os.path.basename(source_file_name))
|
804 | 794 | if options['output-base-name']:
|
805 |
| - output_base = options['output-base-name'].format(counter=counter) |
| 795 | + output_base = options['output-base-name'] |
806 | 796 | else:
|
| 797 | + counter = document.attributes.get('_plot_counter', 0) + 1 |
| 798 | + document.attributes['_plot_counter'] = counter |
807 | 799 | output_base = '%s-%d.py' % (base, counter)
|
808 | 800 | function_name = None
|
809 | 801 | caption = options.get('caption', '')
|
|
0 commit comments