You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
deff():
''' >>> f() 2 '''return2
Launching pdoc on that file with pdoc --html test.py will produce a HTML file where the docstring is replaced by the following code:
For anyone who stumbled upon this issue. It does work well now but you need to make sure to keep the indentation on the doctest part be the same as on the docstring text.
Activity
peterjc commentedon Sep 8, 2017
I would retitle this slightly, but can confirm that pdoc does not nicely render docstests in docstrings. Example:
Then
Gives:
peterjc commentedon Sep 8, 2017
This seems to be a limitation of the markdown rendering engine - which makes sense after all,
>>>is not part of the Markdown language.If pdoc supported reStructuredText as input, that does include support for
>>>doctests - see #111.cortesi commentedon Jun 3, 2018
Please see #153 for a unified discussion ticket about docstring flavors.
jpc commentedon Oct 3, 2025
For anyone who stumbled upon this issue. It does work well now but you need to make sure to keep the indentation on the doctest part be the same as on the docstring text.
In other words this works:
this does not: