-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Allow attributes to be documented using comments above the attribute #446
Comments
I've just had a try and it seems that even with |
This has been partially discussed, but I myself don't remember where, so no problem, and thanks for the feature request 😊 So, supporting docstrings above attributes is a no-go. It would indeed make things confusing, especially for the first docstring in a module: is it the module's docstring, or the first attribute's docstring? About We could consider adding an option to support these comments, using About intuitiveness of docstrings below attributes: maybe you'll find it consistent with how docstrings are added below signatures of functions/classes? Also note that instead of documenting attributes individually, you can document them using an |
Interesting, I get where you're coming from. I see the "docstring after function definition" argument, but I still don't find it very as intuitive. Here's the link to the sphinx docs on attributes, you'll have to scroll down. Overall, I'd still really like this feature, but I understand why it's not a priority. |
OK, noted 🙂 Maybe someone with Thanks for the link! |
(Please accept my apology if this is already discussed or resolved somewhere, I've looked but couldn't find anything)
Is your feature request related to a problem? Please describe.
Currently when documenting attributes (in google style docstrings), I use the following:
I don't find this very intuitive.
Describe the solution you'd like
It would be great if comments before the attribute could be used to document it. AFAIK this is support in sphinx, as follows:
It would be great if this style could be supported while otherwise still using google style docstrings?
I've just tried this and neither pycharm or black complain about the lack of space after the
#
- I guess because they know about the sphinx style.Describe alternatives you've considered
I guess we could use docstrings above the attribute, but then the association of attributes would be unclear or would change implicitly based on a configuration parameter, which would not be good.
Additional context
I'm going to be using mkdocstrings to document pydantic v2 and perhaps pydantic-core, would be great if we could support this before I start in a few weeks if you agree it's acceptable?
The text was updated successfully, but these errors were encountered: