-
Notifications
You must be signed in to change notification settings - Fork 21
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
dynamic loading of an instance should prioritize a statically written docstring (if it exists) #308
Comments
from #307 |
What the "official" (PEP 257) sources say about documenting attributes.
What sphinx accepts as documenting attributes
class Foo:
"""Docstring for class Foo."""
#: Doc comment for class attribute Foo.bar.
#: It can have multiple lines.
bar = 1
flox = 1.5 #: Doc comment for Foo.flox. One line only.
baz = 2
"""Docstring for class attribute Foo.baz."""
def __init__(self):
#: Doc comment for instance attribute qux.
self.qux = 3
self.spam = 4
"""Docstring for instance attribute spam.""" My takeaway is all |
Generally, dynamic loading works well for modules, classes and functions, but can behave surprisingly for instances. This is because what it means to document an instance is ambiguous.
Consider below:
Note that dynamically loading produces these behaviors:
some_func.__doc__
is used.some_int
orsome_other_int
, the underlying docstringint.__doc__
is also used.some_other_int
.For cases where a variable has a docstring defined below it, we should favor that docstring, so it matches what happens statically.
The text was updated successfully, but these errors were encountered: