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 f3e2fa1

Browse filesBrowse files
committed
Merge pull request #4702 from hamogu/fix_4702
sphinxext/plot_directive does not accept a caption
2 parents 08cb2c0 + b38a951 commit f3e2fa1
Copy full SHA for f3e2fa1

File tree

Expand file treeCollapse file tree

5 files changed

+36
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+36
-4
lines changed
Open diff view settings
Collapse file

‎lib/matplotlib/sphinxext/plot_directive.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,6 @@ def render_figures(code, code_path, output_dir, output_base, context,
662662

663663

664664
def run(arguments, content, options, state_machine, state, lineno):
665-
# The user may provide a filename *or* Python code content, but not both
666-
if arguments and content:
667-
raise RuntimeError("plot:: directive can't have both args and content")
668-
669665
document = state_machine.document
670666
config = document.settings.env.config
671667
nofigs = 'nofigs' in options
Collapse file

‎lib/matplotlib/sphinxext/tests/test_tinypages.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/tests/test_tinypages.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,8 @@ def plot_file(num):
8383
with open(pjoin(self.html_dir, 'some_plots.html'), 'rt') as fobj:
8484
html_contents = fobj.read()
8585
assert_true('# Only a comment' in html_contents)
86+
# check plot defined in external file.
87+
assert_true(file_same(range_4, pjoin(self.html_dir, 'range4.png')))
88+
assert_true(file_same(range_6, pjoin(self.html_dir, 'range6.png')))
89+
# check if figure caption made it into html file
90+
assert_true('This is the caption for plot 15.' in html_contents)
Collapse file
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from matplotlib import pyplot as plt
2+
3+
plt.figure()
4+
plt.plot(range(4))
5+
plt.show()
Collapse file
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from matplotlib import pyplot as plt
2+
3+
4+
def range4():
5+
'''This is never be called if plot_directive works as expected.'''
6+
raise NotImplementedError
7+
8+
9+
def range6():
10+
'''This is the function that should be executed.'''
11+
plt.figure()
12+
plt.plot(range(6))
13+
plt.show()
Collapse file

‎lib/matplotlib/sphinxext/tests/tinypages/some_plots.rst‎

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/tests/tinypages/some_plots.rst
+13Lines changed: 13 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,16 @@ Plot 14 uses ``include-source``:
114114
:include-source:
115115

116116
# Only a comment
117+
118+
Plot 15 uses an external file with the plot commands and a caption:
119+
120+
.. plot:: range4.py
121+
122+
This is the caption for plot 15.
123+
124+
125+
Plot 16 uses a specific function in a file with plot commands:
126+
127+
.. plot:: range6.py range6
128+
129+

0 commit comments

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