Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 486b385

Browse files
jjcaballerotacaswell
authored andcommitted
for non-html output, let sphinx pick the best format (cherry-pick change from pr-14683)
1 parent e772c1f commit 486b385

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def remove_coding(text):
357357
TEMPLATE = """
358358
{{ source_code }}
359359
360-
{{ only_html }}
360+
.. only:: html
361361
362362
{% if source_link or (html_show_formats and not multi_image) %}
363363
(
@@ -393,27 +393,15 @@ def remove_coding(text):
393393
{{ caption }}
394394
{% endfor %}
395395
396-
{{ only_latex }}
396+
.. only:: not html
397397
398398
{% for img in images %}
399-
{% if 'pdf' in img.formats -%}
400-
.. figure:: {{ build_dir }}/{{ img.basename }}.pdf
399+
.. figure:: {{ build_dir }}/{{ img.basename }}.*
401400
{% for option in options -%}
402401
{{ option }}
403402
{% endfor %}
404403
405404
{{ caption }}
406-
{% endif -%}
407-
{% endfor %}
408-
409-
{{ only_texinfo }}
410-
411-
{% for img in images %}
412-
.. image:: {{ build_dir }}/{{ img.basename }}.png
413-
{% for option in options -%}
414-
{{ option }}
415-
{% endfor %}
416-
417405
{% endfor %}
418406
419407
"""
@@ -813,10 +801,6 @@ def run(arguments, content, options, state_machine, state, lineno):
813801
':%s: %s' % (key, val) for key, val in six.iteritems(options)
814802
if key in ('alt', 'height', 'width', 'scale', 'align', 'class')]
815803

816-
only_html = ".. only:: html"
817-
only_latex = ".. only:: latex"
818-
only_texinfo = ".. only:: texinfo"
819-
820804
# Not-None src_link signals the need for a source link in the generated
821805
# html
822806
if j == 0 and config.plot_html_show_source_link:
@@ -830,9 +814,6 @@ def run(arguments, content, options, state_machine, state, lineno):
830814
build_dir=build_dir_link,
831815
source_link=src_link,
832816
multi_image=len(images) > 1,
833-
only_html=only_html,
834-
only_latex=only_latex,
835-
only_texinfo=only_texinfo,
836817
options=opts,
837818
images=images,
838819
source_code=source_code,

0 commit comments

Comments
 (0)