-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Class docstrings are never displayed #19
Comments
My bad, there is also the following block, but it does not seem to display anything in my case. Any idea why ? python/src/mkdocstrings_handlers/python/templates/material/_base/class.html Lines 78 to 80 in b43e1a5
|
You can try to run mkdocs with the |
The
If you want to replicate, I have pushed a branch |
Thanks, I'll use that branch to debug! Happy Easter 😄 |
OK I see the issue, its that you define parameters section in docstring classes, and the Google parser tries to access parameters on the class itself (which obviously fails as classes don't have parameters in Griffe's model). I'll make sure the exception is caught to fix it. In the future maybe we can try to use the class' init method instead of the class itself. Note that you can also move the parameters section (args) into the init method, as it's better supported (ability to warn about missing types and unknown parameters, to pick up type annotations in the signature, and to make cross-references of them). |
Will release soon, closing 🙂 |
Thanks for the quick response!
It does work, but it has the drawback of splitting the docstring in two and forcing the parameters section below everything else. Since it is very common to document the parameters in the class docstring, it would be best, as you said, to use the For instance, adding to the @property
def parameters(self):
return self.members['__init__'].parameters Edit: just checked, and it works very well! |
Ah, clever! Do you want to send a PR 😄? |
Issue mkdocstrings/python#19: mkdocstrings/python#19 Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
Describe the bug
The class docstrings are never displayed.
Screenshots
With the following class
I get
when
merge_init_into_class
is false andwhen it is true.
System (please complete the following information):
mkdocstrings-python
version: 0.6.6Additional context
If I understand correctly the following logic, a docstring is displayed only if
merge_init_into_class=true
and the__init__
function has a docstring, but it is never the one from the class itself.python/src/mkdocstrings_handlers/python/templates/material/_base/class.html
Lines 82 to 88 in b43e1a5
I think that if
merge_init_into_class=false
or__init__
does not have a docstring, the docstring of the class should be displayed, if any. Ifmerge_init_into_class=true
and both__init__
and the class have a docstring, it is more complicated but IMO, the class docstring should have precedence.The text was updated successfully, but these errors were encountered: