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 f624bcd

Browse filesBrowse files
authored
Merge pull request #15190 from tacaswell/auto-backport-of-pr-14683-on-v3.1.x
Backport PR #14683: For non-html output, let sphinx pick the best format
2 parents c615fd4 + 56f2946 commit f624bcd
Copy full SHA for f624bcd

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+3
-22
lines changed

‎lib/matplotlib/sphinxext/plot_directive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
+3-22Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def remove_coding(text):
367367
TEMPLATE = """
368368
{{ source_code }}
369369
370-
{{ only_html }}
370+
.. only:: html
371371
372372
{% if source_link or (html_show_formats and not multi_image) %}
373373
(
@@ -403,27 +403,15 @@ def remove_coding(text):
403403
{{ caption }}
404404
{% endfor %}
405405
406-
{{ only_latex }}
406+
.. only:: not html
407407
408408
{% for img in images %}
409-
{% if 'pdf' in img.formats -%}
410-
.. figure:: {{ build_dir }}/{{ img.basename }}.pdf
409+
.. figure:: {{ build_dir }}/{{ img.basename }}.*
411410
{% for option in options -%}
412411
{{ option }}
413412
{% endfor %}
414413
415414
{{ caption }}
416-
{% endif -%}
417-
{% endfor %}
418-
419-
{{ only_texinfo }}
420-
421-
{% for img in images %}
422-
.. image:: {{ build_dir }}/{{ img.basename }}.png
423-
{% for option in options -%}
424-
{{ option }}
425-
{% endfor %}
426-
427415
{% endfor %}
428416
429417
"""
@@ -794,10 +782,6 @@ def run(arguments, content, options, state_machine, state, lineno):
794782
':%s: %s' % (key, val) for key, val in options.items()
795783
if key in ('alt', 'height', 'width', 'scale', 'align', 'class')]
796784

797-
only_html = ".. only:: html"
798-
only_latex = ".. only:: latex"
799-
only_texinfo = ".. only:: texinfo"
800-
801785
# Not-None src_link signals the need for a source link in the generated
802786
# html
803787
if j == 0 and config.plot_html_show_source_link:
@@ -811,9 +795,6 @@ def run(arguments, content, options, state_machine, state, lineno):
811795
build_dir=build_dir_link,
812796
source_link=src_link,
813797
multi_image=len(images) > 1,
814-
only_html=only_html,
815-
only_latex=only_latex,
816-
only_texinfo=only_texinfo,
817798
options=opts,
818799
images=images,
819800
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.