-
-
Notifications
You must be signed in to change notification settings - Fork 167
BUG: Plot(s) not rendered if docstring ends with normal text after show command #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The restructuredtext markup:
means that "Some text." is a part of the doctest block (in particular, it's the output from the previous command) --- the newline is necessary if you want it to be parsed differently. So this seems to be working as expected per spec. |
However, I would expect the |
Actually that's a typo by me. I forgott to add the blank line in-between. The snippet should read:
```
from numpydoc.docscrape_sphinx import SphinxDocString
doc =SphinxDocString("""
Examples
--------
>> import matplotlib.pyplot as plt
>> plt.plot([1,2,3],[4,5,6])
>> plt.show()
Some text.
""", config=dict(use_plots=True)) print(doc)
```
(Updated description in first post)
|
Right, however also that should still render the plot since it's still valid doctest input. |
Meaning I should raise an issue with matplotlib? I will do that and ask whether they intend to support this pattern (their documentation does only feature basic examples). If not this might be something that numpydoc needs to handle itself. |
I'm not entirely sure whether this is a bug in numpydoc or matplotlib.sphinxext (where the error message happens). This is my best guess right now and I hope someone with more insight into the inner workings of both can pinpoint the bug.
Bug description
When using the plot directive implicitly in docstrings sometimes the plots are not included in the rendered HTML documentation. This happens when the docstring ends with a normal text line after the
>>> plt.show()
statement. It seems like The cause lies in howSphinxDocString
parses the input (see snippets below). In this special case the functions inplot_directive.py
won't prefix the last line with#
. As a consequence the last line raises an exception on line 524 when callingsix.exec_(code, ns)
inplot_directive.py
(functionrun_code
).Reproduction
I have created a minimal dummy project to demonstrate the behavior:
https://github.com/lagru/docstring-plot-bug-demo
As stated the possible cause might lie here:
which yields
However I would expect this output:
Note how the last line isn't part of the
plot::
directive in contrast to the actual output.Other info
Setup
OS: Manjaro 17.1.7, x86_64 Linux 4.14.30-1-MANJARO
python 3.6.5
numpydoc 0.7.0
sphinx 1.7.2
matplotlib 2.2.2
The text was updated successfully, but these errors were encountered: