-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Hi! I would like to start by saying this project has made mkdocs usable for our team and we are SO excited about finally ditching RST! I cannot emphasize this enough: Thank. You.
The only thing we are missing is that, currently, mkdocstrings doesn't support an Examples section, which normally include doctest formatted blocks. For example:
def example_function(arg1, kwarg=None) -> object:
"""
Example function to demonstrate how APIs are rendered
Parameters:
arg1 (dict): Some description for this argument.
This type (in parenthesis) is ignored.
kwarg: Some more descriptions
Returns:
A description for the returned value
Examples:
>>> 2 + 2 == 4
False
"""
passgets rendered as:
The style is not bad, but it could be even better! Notice how pytest is able to parse the block just fine.
I can get what I want by using this other docstring:
def example_function(arg1, kwarg=None) -> object:
"""
Example function to demonstrate how APIs are rendered
Parameters:
arg1 (dict): Some description for this argument.
This type (in parenthesis) is ignored.
kwarg: Some more descriptions
Returns:
A description for the returned value
__Examples__
```python
>>> 2 + 2 == 4
False
```
"""
pass, but I find it a bit annoying (in order of importance):
- Manually hardcoding the
Examplesheading style - Having to specify the code fences
- Needing an extra blank line before the closing triple backticks so
pytestcan get the doctests correctly.
Maybe a good compromise would be to just add Examples to the recognized headers? That way I could write:
def example_function(arg1, kwarg=None) -> object:
"""
Example function to demonstrate how APIs are rendered
Parameters:
arg1 (dict): Some description for this argument.
This type (in parenthesis) is ignored.
kwarg: Some more descriptions
Returns:
A description for the returned value
Examples:
```python
>>> 2 + 2 == 4
False
```
"""
pass, which currently does not work as intended:
I'd be happy to help and contribute a PR if needed, but if I understood correctly, you are currently refactoring the backend and I don't know if this is the best moment to add a feature.
Thanks a lot!


