sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.61k stars 2.13k forks source link

support `prop: Annotated[str, typing.Doc("...")]` as property document #13100

Closed trim21 closed 2 weeks ago

trim21 commented 2 weeks ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

PEP 727 support annotated types and add new class typing.Doc(backport with typing_extensions.Doc, this can be used to add doc to class property, and I hope sphinx autodoc could support this

for example: from this:

class File(NamedTuple):
    name: str
    """file name"""

to this:

class File(NamedTuple):
    name: Annotated[str, typing_extensions.Doc("file name")]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

AA-Turner commented 2 weeks ago

PEP 727 isn't accepted (and personally, I don't think it's the right solution to the problem discussed). As such I'll close this.

A

trim21 commented 2 weeks ago

do we consider add this feature if it's accepted?

AA-Turner commented 2 weeks ago

Perhaps. Though typing.Doc has several drawbacks, so perhaps not.

A