mkdocstrings / griffe

Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API.
https://mkdocstrings.github.io/griffe
ISC License
267 stars 38 forks source link

numpydoc sections not represented as its own block, if first in docstring #214

Closed machow closed 5 months ago

machow commented 8 months ago

Describe the bug

For a function with a docstring like this:

def f():
    """
    one liner, this isn't shown

    longer description, this isn't shown

    See Also
    --------
    [related function, this is shown](#related_function)
    """

griffe's numpydoc parses produces a single DocstringSectionText, with all the contents.

WDYT of editing this line of the numpydoc parse, to ensure any section marked with lines (----) is its own DocstringSectionText?

https://github.com/mkdocstrings/griffe/blob/main/src/griffe/docstrings/numpy.py#L816

This way, various sections like See Also will be in their own DocstringSectionText, regardless of whether they're...

pawamoy commented 8 months ago

Definitely looks like a bug in the parser! Also, yeah, I was planning to add support for generic admonitions, just like in the Google parser.

machow commented 8 months ago

I can work on a quick PR tomorrow for the numpydoc parser! Is DocstringSectionAdmonition the catch-all for unknown sections? I think because I focused initially on numpydoc format in quartodoc, I totally missed that this piece existed in the google style parser 😅

(guessing from this google parser line)

pawamoy commented 8 months ago

Is DocstringSectionAdmonition the catch-all for unknown sections?

Yes!

A PR would be awesome, thanks a lot :)