Skip to content

Commit 802e267

Browse files
committed
BUG: don't show parens, comma when no source link
plot_directive displaying empty parens when no figures and no source required. Was also prepending a comma to list of images when there was source links not required.
1 parent d1388d3 commit 802e267

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ def remove_coding(text):
346346
347347
{{ only_html }}
348348
349-
{% if (source_link and html_show_source_link) or (html_show_formats and not multi_image) %}
349+
{% if source_link or (html_show_formats and not multi_image) %}
350350
(
351-
{%- if source_link and html_show_source_link -%}
351+
{%- if source_link -%}
352352
`Source code <{{ source_link }}>`__
353353
{%- endif -%}
354354
{%- if html_show_formats and not multi_image -%}
@@ -768,7 +768,9 @@ def run(arguments, content, options, state_machine, state, lineno):
768768
only_latex = ".. only:: latex"
769769
only_texinfo = ".. only:: texinfo"
770770

771-
if j == 0:
771+
# Not-None src_link signals the need for a source link in the generated
772+
# html
773+
if j == 0 and config.plot_html_show_source_link:
772774
src_link = source_link
773775
else:
774776
src_link = None
@@ -778,15 +780,14 @@ def run(arguments, content, options, state_machine, state, lineno):
778780
dest_dir=dest_dir_link,
779781
build_dir=build_dir_link,
780782
source_link=src_link,
781-
html_show_source_link=config.plot_html_show_source_link,
782783
multi_image=len(images) > 1,
783784
only_html=only_html,
784785
only_latex=only_latex,
785786
only_texinfo=only_texinfo,
786787
options=opts,
787788
images=images,
788789
source_code=source_code,
789-
html_show_formats=config.plot_html_show_formats,
790+
html_show_formats=config.plot_html_show_formats and not nofigs,
790791
caption=caption)
791792

792793
total_lines.extend(result.split("\n"))

0 commit comments

Comments
 (0)