Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pawamoy opened this issue Aug 20, 2023 · 2 comments
Labels
feature New feature or request griffe: docstrings Related to docstring parsing griffe: numpy Related to Numpydoc-style docstrings

Comments

@pawamoy
Copy link
Member

pawamoy commented Aug 20, 2023

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

@pawamoy pawamoy added feature New feature or request griffe: docstrings Related to docstring parsing griffe: numpy Related to Numpydoc-style docstrings labels Aug 20, 2023
@pawamoy pawamoy changed the title numpy: Cross-references for functions/classes/modules sections numpy: Cross-references for functions/classes signatures (docstring sections) Aug 20, 2023
@Simon-Bru
Copy link

Simon-Bru commented Feb 6, 2024

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

@pawamoy
Copy link
Member Author

pawamoy commented Feb 6, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request griffe: docstrings Related to docstring parsing griffe: numpy Related to Numpydoc-style docstrings
Projects
None yet
Development

No branches or pull requests

2 participants