griffe icon indicating copy to clipboard operation
griffe copied to clipboard

numpy: Cross-references for functions/classes signatures (docstring sections)

Open pawamoy opened this issue 2 years ago • 2 comments

Support automatic cross-references for documented functions/methods and classes signatures through the corresponding docstring sections.

pawamoy avatar Aug 20 '23 08:08 pawamoy

Not sure what you mean exactly , but I got cross-reference working in my docstring using the TOC entry. This part of the doc got me on the track : https://mkdocstrings.github.io/python/

image

Then I managed to reference a method of separate class in docstring using [Link Label][my_package.module.function]

Hope i'm not totally off subject and that can help

Simon-Bru avatar Feb 06 '24 10:02 Simon-Bru

Thanks for helping!

Here's what I meant. In your docstrings, you can write sections to document available classes, functions or methods:

class Flags:
    ...

class A:
    """Class A.

    Methods
    -------
    method_a(value)
        Method a.
    method_b(flag=Flags.NONE, store=False)
        Method b.
    """
    def method_a(self, value: str):
        """Method a."""

    def method_b(self, flag: int, store: bool):
        """Method b."""

The goal here is to re-parse these signatures (method_a(value) and method_b(flag=Flags.NONE, store=False)), which are just text in the docstring, as Griffe expressions, which will allow the renderer to automatically add cross-references to the parameters (value maybe, flag and store for sure) or values (flags.None).

pawamoy avatar Feb 06 '24 11:02 pawamoy