-
-
Notifications
You must be signed in to change notification settings - Fork 200
Doctests are interpreted by the HTML template #63
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
I would retitle this slightly, but can confirm that pdoc does not nicely render docstests in docstrings. Example: from __future__ import print_function
def double(x):
"""Return double the input value.
>>> double(5)
10
>>> double(1.25)
2.5
"""
return x * 2
if __name__ == "__main__":
for v in [0.1, 3, 123]:
print("Doubling %r gives %r" % (v, double(v))) Then
Gives: ...
<section id="section-items">
<h2 class="section-title" id="header-functions">Functions</h2>
<div class="item">
<div class="name def" id="example.double">
<p>def <span class="ident">double</span>(</p><p>x)</p>
</div>
<div class="desc"><p>Return double the input value.</p>
<blockquote>
<blockquote>
<blockquote>
<p>double(5)
10
double(1.25)
2.5</p>
</blockquote>
</blockquote>
</blockquote></div>
<div class="source_cont">
... |
This seems to be a limitation of the markdown rendering engine - which makes sense after all, If pdoc supported reStructuredText as input, that does include support for |
Please see #153 for a unified discussion ticket about docstring flavors. |
When producing the output in HTML mode, doctests are simply interpreted as if they were part of markdown syntax and are replaced by (three) blockquotes.
For instance if you have the following code in a
test.py
file:Launching
pdoc
on that file withpdoc --html test.py
will produce a HTML file where the docstring is replaced by the following code:Therefore the
>>>
are removed and the line return is ignored which makes the doctests hardly readable.The text was updated successfully, but these errors were encountered: