X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/matplotlib/sphinxext/plot_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,6 @@ def render_figures(code, code_path, output_dir, output_base, context,


def run(arguments, content, options, state_machine, state, lineno):
# The user may provide a filename *or* Python code content, but not both
if arguments and content:
raise RuntimeError("plot:: directive can't have both args and content")

document = state_machine.document
config = document.settings.env.config
nofigs = 'nofigs' in options
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/sphinxext/tests/test_tinypages.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ def plot_file(num):
with open(pjoin(self.html_dir, 'some_plots.html'), 'rt') as fobj:
html_contents = fobj.read()
assert_true('# Only a comment' in html_contents)
# check plot defined in external file.
assert_true(file_same(range_4, pjoin(self.html_dir, 'range4.png')))
assert_true(file_same(range_6, pjoin(self.html_dir, 'range6.png')))
# check if figure caption made it into html file
assert_true('This is the caption for plot 15.' in html_contents)
5 changes: 5 additions & 0 deletions lib/matplotlib/sphinxext/tests/tinypages/range4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from matplotlib import pyplot as plt

plt.figure()
plt.plot(range(4))
plt.show()
13 changes: 13 additions & 0 deletions lib/matplotlib/sphinxext/tests/tinypages/range6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from matplotlib import pyplot as plt


def range4():
'''This is never be called if plot_directive works as expected.'''
raise NotImplementedError


def range6():
'''This is the function that should be executed.'''
plt.figure()
plt.plot(range(6))
plt.show()
13 changes: 13 additions & 0 deletions lib/matplotlib/sphinxext/tests/tinypages/some_plots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,16 @@ Plot 14 uses ``include-source``:
:include-source:

# Only a comment

Plot 15 uses an external file with the plot commands and a caption:

.. plot:: range4.py

This is the caption for plot 15.


Plot 16 uses a specific function in a file with plot commands:

.. plot:: range6.py range6


X Tutup