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

Support PEP 727 Annotated/Doc annotations? #755

Open
jeremander opened this issue Oct 26, 2024 · 2 comments
Open

Support PEP 727 Annotated/Doc annotations? #755

jeremander opened this issue Oct 26, 2024 · 2 comments

Comments

@jeremander
Copy link

Problem Description

PEP 727 proposes a standard syntax for applying documentation strings to function parameters, return values, class variables, etc. using Annotated/Doc. While the PEP has not yet been accepted (and may or may not be), some Python libraries like pydantic and FastAPI are already using it regardless.

Proposal

It would be nice if pdoc could support this, extracting Doc elements from Annotated type annotations and inserting the text into the appropriate section of the rendered documentation. This could be used in lieu of or in conjunction with existing docstring styles like Google or numpy.

Alternatives

I don't think any mainstream doc generators are supporting this syntax yet, but there is an extension for mkdocstrings that does seem to support it.

Additional context

If PEP 727 is accepted, then the typing module will introduce Doc. But otherwise, Doc is expected to remain in the 3rd party typing_extensions library indefinitely.

@mhils
Copy link
Member

mhils commented Oct 26, 2024

I'd be open to a well-written PR if the PEP gets accepted, but to be frank I'm not a fan of the syntax at all. So unless this becomes widely used, I don't want to maintain any of it. 🙊

@jeremander
Copy link
Author

Understandable. I don't love the syntax either, but I do like the idea of docs-in-annotations generally. I guess we wait and see what happens in terms of adoption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants