Skip to content

Commit f322125

Browse files
committed
Rename output-base-name to image-basename
1 parent e0be21e commit f322125

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
4848
The ``.. plot::`` directive supports the following options:
4949
50-
``:output-base-name:`` : str
50+
``:image-basename:`` : str
5151
The base name (without the extension) of the outputted image files. The
5252
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 output-base-name for each
53+
the RST document if no script is provided. The image-basename for each
5454
plot directive must be unique.
5555
5656
``:format:`` : {'python', 'doctest'}
@@ -273,7 +273,7 @@ class PlotDirective(Directive):
273273
'scale': directives.nonnegative_int,
274274
'align': Image.align,
275275
'class': directives.class_option,
276-
'output-base-name': directives.unchanged,
276+
'image-basename': directives.unchanged,
277277
'include-source': _option_boolean,
278278
'show-source-link': _option_boolean,
279279
'format': _option_format,
@@ -642,16 +642,16 @@ def check_output_base_name(env, output_base):
642642

643643
if '.' in output_base or '/' in output_base:
644644
raise PlotError(
645-
f"The output-base-name '{output_base}' is invalid. "
645+
f"The image-basename '{output_base}' is invalid. "
646646
f"It must not contain dots or slashes.")
647647

648648
for d in env.mpl_custom_base_names:
649649
if output_base in env.mpl_custom_base_names[d]:
650650
if d == docname:
651651
raise PlotError(
652-
f"The output-base-name "
652+
f"The image-basename "
653653
f"{output_base}' is used multiple times.")
654-
raise PlotError(f"The output-base-name "
654+
raise PlotError(f"The image-basename "
655655
f"'{output_base}' is used multiple times "
656656
f"(it is also used in {env.doc2path(d)}).")
657657

@@ -793,7 +793,7 @@ def run(arguments, content, options, state_machine, state, lineno):
793793

794794
options.setdefault('include-source', config.plot_include_source)
795795
options.setdefault('show-source-link', config.plot_html_show_source_link)
796-
options.setdefault('output-base-name', None)
796+
options.setdefault('image-basename', None)
797797

798798
if 'class' in options:
799799
# classes are parsed into a list of string, and output by simply
@@ -835,16 +835,16 @@ def run(arguments, content, options, state_machine, state, lineno):
835835
function_name = None
836836

837837
code = Path(source_file_name).read_text(encoding='utf-8')
838-
if options['output-base-name']:
839-
output_base = options['output-base-name']
838+
if options['image-basename']:
839+
output_base = options['image-basename']
840840
check_output_base_name(env, output_base)
841841
else:
842842
output_base = os.path.basename(source_file_name)
843843
else:
844844
source_file_name = rst_file
845845
code = textwrap.dedent("\n".join(map(str, content)))
846-
if options['output-base-name']:
847-
output_base = options['output-base-name']
846+
if options['image-basename']:
847+
output_base = options['image-basename']
848848
check_output_base_name(env, output_base)
849849
else:
850850
base, ext = os.path.splitext(os.path.basename(source_file_name))

lib/matplotlib/tests/test_sphinxext.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ def plot_directive_file(num):
9696
assert filecmp.cmp(range_6, plot_file(17))
9797
# plot 22 is from the range6.py file again, but a different function
9898
assert filecmp.cmp(range_10, img_dir / 'range6_range10.png')
99-
# plots 23 and 24 use a custom base name
100-
assert filecmp.cmp(range_6, img_dir / 'custom-base-name-6.png')
101-
assert filecmp.cmp(range_4, img_dir / 'custom-base-name-4.png')
99+
# plots 23 and 24 use a custom basename
100+
assert filecmp.cmp(range_6, img_dir / 'custom-basename-6.png')
101+
assert filecmp.cmp(range_4, img_dir / 'custom-basename-4.png')
102102

103103
# Modify the included plot
104104
contents = (tmp_path / 'included_plot_21.rst').read_bytes()

lib/matplotlib/tests/tinypages/some_plots.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ Plot 22 uses a different specific function in a file with plot commands:
175175

176176
.. plot:: range6.py range10
177177

178-
Plots 23 and 24 use output-base-name.
178+
Plots 23 and 24 use image-basename.
179179

180180
.. plot::
181-
:output-base-name: custom-base-name-6
181+
:image-basename: custom-basename-6
182182

183183
plt.plot(range(6))
184184

185185
.. plot:: range4.py
186-
:output-base-name: custom-base-name-4
186+
:image-basename: custom-basename-4

0 commit comments

Comments
 (0)