-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Instance variables set using __pdoc__ don't work #107
Comments
Instance variables are detected by parsing the AST. I'd prefer a lower tech solution. You must write each instance variable on its own line, or modify |
Okay, thanks. I'm trying to work out how to do the latter; nothing I try is working. From the example above, would I do this? __pdoc__ = {}
__pdoc__['Foo.d'] = "Docstring for Foo's d instance variable."
class Foo:
a,b,c = 0, 1, 2
def __init__(self):
self.d, self.e, self.f = 3, 4, 5 or |
So It looks like your example doesn't work, which means this is probably a bug. It looks like putting each instance variable on its own line does work though. |
Thanks. Shall I file a bug for that related-but-separate issue? |
This issue is fine. I renamed the title. I don't think I'll ever support multiple instance variables defined on the same line. |
+1 for adding support for multiple instance variables defined on the same line. Wanted to see if there wasn't an issue on this already before opening one. My use case: (self.var1, self.var2, self.var3) = self.method_that_returns_tuple() Hopefully in future I can get some time and submit a pull request with this added. Thanks for the great tool, Andrew! |
Hi, current pdoc maintainer here! The recommended workaround to do this now is to document your variables on the class itself, see I'll close this here as we have (at least temporarily) removed |
Is there any way, template, macros, whatever, to force any instance variable to show up in the documentation regardless their docstring status? Sometimes this variables don't need any explanation but having them in the documentation is needed to give the users all the clear information they need A very simple example that come to mind is a Vector class class Vector:
def __init__(self):
self.x = 0.0
self.y = 0.0
self.z = 0.0 Now x, y and z won't appear in the documentation, unless I document them. But should I really have to document them? and with what? class Vector:
def __init__(self):
self.x = 0.0
""" The vector's x component"""
self.y = 0.0
""" The vector's y component"""
self.z = 0.0
""" The vector's z component""" In my opinion It is kind of redundant. |
You can write a template that overrides Specifically: {% macro is_public(doc) %}
{% if doc.kind == "variable" %}
true
{% else %}
{{ default_is_public(doc) }}
{% endif %}
{% endmacro %} |
This doesn't work, the problem is that instance or class variables seems not being picked up by pdoc's api at all, unless they are commented, so the never get passed to that macro in the first place. I tried and they are not included in what is returned by methods such as And as a small note, they are public in my example, so is not really that the issue. They should be picked up like any other member. A method, for instance, even if not documented, ends up in the documentation Also probably worth mentioning, I'm using pdoc version 12.2.0 installed on python 3.7 through pip |
True - we didn't pick them up so far as they are excluded in the default template. #461 fixes this! |
Thank you, works like a charm :) |
If I have something like:
Class variables a,b,c show up in the generated docs, but instance variables d,e,f do not.
Expected result: instance variables declared in this manner should show up in generated docs.
The text was updated successfully, but these errors were encountered: