-
Notifications
You must be signed in to change notification settings - Fork 51
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
Lookup of name in annotation fails on reparented object #295
Comments
Keeping a layer with the "true structure" will also allow to display the Class in the module summary where they are actually defined, but link to where they are exported. It can be confusing to see an empty module because all classes are exported. |
Agreed. I've had several cases when I was looking at a class or function in Twisted and I wondered "where is this published?" Although it's usually not too hard to find out with the right |
I've think about this a bit and I think we could maintain 2 different models concurrently. One model that would strictly represent the python sources and would include all python language related processing ( Then, the current model could be simplified (to defer to the underlying objects) and focused on the public API location of the objects. The reparenting process itself could be kept, but it should be enhanced to understand multiple re-exporting such that it fixes #184. A new attribute could be added : The workflow for constructing the model should be changed from : AST - ( To : AST - ( Tell me what you think, Thanks |
Forgot about I'll try to make it the more simple as possible but first we should settle on a rationale about re-exporting. Here's what I suggest :
So all in all, we need to create proper |
To be clear: when re-exporting a class, all it's members to a new module, we need both original class context as well as it's parent to resolve names, so Such approach could sound rather complex, but it's probably the best way we have with our current model. The other path to look into (as @mthuurne said) is to resolve the annotation and docstrings links at a time when no reparenting has been taken place yet. But there is another issue with that, the linker currently generates relative URLs when it can to avoid reloading the same page. If a function links to another function in the same module, the link will be relative, but, if this function get re-exported, the link will then be broken. So we need the re-exporting information to compute the right relative links. (I have started a draft for improving the linker in branch
To answer these concerns, the proposed approach will keep the original true structure of the code, but will move around what's going to be the actual documented object and replaces it. But yes it would be good to have the distinction in between the model and the view-model, but I don't see a clear path towards such design. Tell me what you think, |
…s named localNameToFullName(), which is used as a fallback method when the name cannot be found on the regular model. This will help fix #295
Disregard my three last comments. See #723 |
twisted.logger.extractField()
has return typetyping.Any
, but in the output this is not linked to the standard library documentation, despite the intersphinx inventory being available and other types being linked successfully.What I think is happening here is that
extractField()
is implemented intwisted.logger._flatten
, which importsAny
from thetyping
module in the standard library. However, by the time the link is resolved, theextractField()
has been moved into thetwisted.logger
module, it's public location. But this module does not importAny
, so the lookup fails.Note that doing the lookup before the move isn't correct either: when we link to other objects that get moved around, that link would be broken after the move. A similar problem occurs if we'd keep a reference to the original parent location and attempt to do a lookup there after all moves have happened, since the target would have been moved away then. I think the only way to do it correctly is to look up the target
Documentable
in a code model that reflects the actual source and when presenting ask thatDocumentable
where in the output it resides and link there.In an earlier discussion of problems related to cyclic imports, I wrote:
@adiroiban replied:
I think that's a good way to look at it: objects have an implementation location, being the source file they're defined in, and a public API location, which is where the user will read about them in the documentation and import them from.
There are more issues related to reparenting, for example #184, in which the same name is re-exported in more than one location. So the mapping between implementation layer and public API layer might not be 1:1.
The text was updated successfully, but these errors were encountered: