NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
449 stars 104 forks source link

Render Python DocTest correctly #328

Closed Hocnonsense closed 1 month ago

Hocnonsense commented 1 month ago

Thanks for this usefull software!

Is your feature request related to a problem? Please describe.

I'm using pydoc-markdown to generate markdown files. However, all things in docstring will be write to markdown almost as-is, and when there is a function:

def iter_rsplit(s: str, sep=";"):
    """
    >>> list(iter_rsplit("a;b;c;d;e;f;g", ";"))
   ['a;b;c;d;e;f;g', 'a;b;c;d;e;f', 'a;b;c;d;e', 'a;b;c;d', 'a;b;c', 'a;b', 'a']
    """
   ...

However, it is not a clear way to view it

Describe the solution you'd like

I would like pydoc-markdown find >>> in docstring and render like this:

<a id="taxon.iter_rsplit"></a>

#### iter\_rsplit

\```python
def iter_rsplit(s: str, sep=";")
\```

example:
\```python
>>> list(iter_rsplit("a;b;c;d;e;f;g", ";"))
['a;b;c;d;e;f;g', 'a;b;c;d;e;f', 'a;b;c;d;e', 'a;b;c;d', 'a;b;c', 'a;b', 'a']
\```

Additional context

All backslashes preceding backquotes within code blocks solely serve to prevent Markdown formatting issues.