-
Notifications
You must be signed in to change notification settings - Fork 49
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
Re-exporting not working when using wildcard import in __init__.py #565
Comments
Hello @Codeberg-AsGithubAlternative-buhtz, thank you very much for your interest into pydoctor, and all the propositions that you do. With this issue, your scratching the limits of our current ast builder. Analyzing wildcard import is something highly complex, that astroid doesn’t even get right. I’m talking about astroid because I’m looking at this library to implement a new ast builder. See #430. But maybe something can be done with the current builder… Solving this issue the right way is not obvious. And I agree it would be good that pydoctor recognize such constructs. What you could do to help out is to write a test case that is expected to fail for now. Then you can look at the ast builder code around the Talk to you later, |
I am sorry I am not deep enough into AST or your code to contribute here. |
And another detail. In the below code I fill the
Only this works
|
It is highly complex to recognize such construct with static analysis. And actually, I'de argue this is not very pythonic. You are basically including everything in your |
In my understanding I don't need the Maybe I missunderstood something? |
No, you're right that the names should be part of the Though, I think we can do something about this kind of construct:
But the names will still have to be statically listed as strings to be recognized by |
This would help a lot. But what is still mysterious for me is that this construct works in Doxygen but not in pydoctor:
I also did some debug testing like this
I assume that the call of |
Yes, pydoctor parses the AST of your source files. This is why is so complicated to infer these kind of stuff. Because pydoctor doesn’t actually import your module. |
But I’ll look at adding better support for wildcard. |
I read a bit about AST but no sure about the practical consequences. When I do |
Yes
Yes also, we have some support for wildcard. I’m just unsure if the reexport logic take into account these kind of imports. I’ll try to have a look soon. |
This is about Re-exporting as described in the documentation.
I have a function
mypackage._mypackage.foo
and a classmypackage._mypackage.Bar
. My goal is that they appear in the documentation asmypackage.foo
andmypackage.Bar
. But currently they don't. Please see the attach minimal example including the generate HTML docu: pydbug.zip.__init__.py
As described in the documentation I try to use the
__all__
variable.But it has no effect.
Sidenote
pip3 install -e .
.pydoctor
via my scriptdocs/hey_doc.py
. It simply extract some meta-data from the package and use it as comandline arguments.EDIT
In my example I do an
import *
.In your documentation about Re-exporting you explicit import all elements.
So when I do
from ._mypackage import foo, Bar
it works. In that case there is also a message about it in the generator output.OK, now we know some more.
I see no choice to explict import all components. I wan' everything and all for all the time. I don't want to think about to import something explicit when I create a new function or class in
_mypackage.py
. I know that PEP8 tells to avoid wildcard imports like from module import *. But in that case it makes sense.The text was updated successfully, but these errors were encountered: