Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c19ebd6

Browse filesBrowse files
authored
Merge pull request #14683 from anntzer/sphinxext-imageformat
MNT: For non-html output, let sphinx pick the best format.
2 parents dcff0d2 + caedd43 commit c19ebd6
Copy full SHA for c19ebd6

File tree

Expand file treeCollapse file tree

1 file changed

+3
-24
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-24
lines changed

‎lib/matplotlib/sphinxext/plot_directive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
+3-24Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def split_code_at_show(text):
348348
TEMPLATE = """
349349
{{ source_code }}
350350
351-
{{ only_html }}
351+
.. only:: html
352352
353353
{% if source_link or (html_show_formats and not multi_image) %}
354354
(
@@ -384,29 +384,15 @@ def split_code_at_show(text):
384384
{{ caption }}
385385
{% endfor %}
386386
387-
{{ only_latex }}
387+
.. only:: not html
388388
389389
{% for img in images %}
390-
{% if 'pdf' in img.formats -%}
391-
.. figure:: {{ build_dir }}/{{ img.basename }}.pdf
390+
.. figure:: {{ build_dir }}/{{ img.basename }}.*
392391
{% for option in options -%}
393392
{{ option }}
394393
{% endfor %}
395394
396395
{{ caption }}
397-
{% endif -%}
398-
{% endfor %}
399-
400-
{{ only_texinfo }}
401-
402-
{% for img in images %}
403-
{% if 'png' in img.formats -%}
404-
.. image:: {{ build_dir }}/{{ img.basename }}.png
405-
{% for option in options -%}
406-
{{ option }}
407-
{% endfor %}
408-
409-
{% endif -%}
410396
{% endfor %}
411397
412398
"""
@@ -777,10 +763,6 @@ def run(arguments, content, options, state_machine, state, lineno):
777763
':%s: %s' % (key, val) for key, val in options.items()
778764
if key in ('alt', 'height', 'width', 'scale', 'align', 'class')]
779765

780-
only_html = ".. only:: html"
781-
only_latex = ".. only:: latex"
782-
only_texinfo = ".. only:: texinfo"
783-
784766
# Not-None src_link signals the need for a source link in the generated
785767
# html
786768
if j == 0 and config.plot_html_show_source_link:
@@ -794,9 +776,6 @@ def run(arguments, content, options, state_machine, state, lineno):
794776
build_dir=build_dir_link,
795777
source_link=src_link,
796778
multi_image=len(images) > 1,
797-
only_html=only_html,
798-
only_latex=only_latex,
799-
only_texinfo=only_texinfo,
800779
options=opts,
801780
images=images,
802781
source_code=source_code,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.