griffe
griffe copied to clipboard
docstrings/sphinx: Support "trim_doctest_flags" option
This trim_doctest_flags
option allows the user to remove doctest flags like # doctest: +FLAG
and <BLANKLINE>
, present in example snippets within docstrings, from the parsed output.
E.g.
def f(x: int) -> int:
"""Test function.
Example:
We want to skip the following test.
>>> 1 + 1 == 3 # doctest: +SKIP
True
And then a few more examples here:
>>> print("a\\n\\nb")
a
<BLANKLINE>
b
>>> 1 + 1 == 2 # doctest: +SKIP
>>> print(list(range(1, 100))) # doctest: +ELLIPSIS
[1, 2, ..., 98, 99]
"""
return x
This is default behaviour in Sphinx. See original discussion / feature request on https://github.com/mkdocstrings/mkdocstrings/issues/386.
The idea is to emulate this behaviour for this sphinx parser in griffe
.
Pre-requisite / blocker for this issue seems to be #7 .