-
Notifications
You must be signed in to change notification settings - Fork 53
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
Provides caching for the linker #498
Conversation
…ching system to even more efficient and works with options same_page_optimization
Codecov Report
@@ Coverage Diff @@
## master #498 +/- ##
==========================================
+ Coverage 89.90% 90.06% +0.16%
==========================================
Files 35 35
Lines 6369 6504 +135
Branches 1436 1463 +27
==========================================
+ Hits 5726 5858 +132
- Misses 391 392 +1
- Partials 252 254 +2
Continue to review full report at Codecov.
|
Note: It does not seem to influence the performance of pydoctor, but many warnings are now displayed only once and not many times! so that's good. |
Thanks for the update. I am a bit busy these days. if @not-my-profile can review this, that would be great :) |
pydoctor/model.py
Outdated
@property | ||
def docstringlinker(self) -> 'epydoc2stan.DocstringLinker': | ||
""" | ||
Returns an instance of L{epydoc2stan.DocstringLinker} suitable for resolving names | ||
in the context of the object scope. | ||
""" | ||
if self._linker is not None: | ||
return self._linker | ||
from pydoctor.epydoc2stan import _CachedEpydocLinker | ||
self._linker = _CachedEpydocLinker(self) | ||
return self._linker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best would be to avoid this workaround cyclic imports.
In order to do that, we should move all code related to the concrete docstring linkers in a new module: docstringlinker.py
. I wonder if this change should happen in this PR though ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better for a separate PR, but also add all this info in a code comment :)
Use string annotation in the linker code when possible and add even more docs to the cached linker. Correct english.
@adiroiban, I don't think @not-my-profile wants to be involved in pydoctor development. He manifested interest into creating a new doc generator based on mypy internals. So I don't think we should wait for his review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,Thanks for the update.
If there is no speedup, I am not sure if it's worth it.
Also by not having repeated errors, it might be ok when you run locally, but for CI, I prefer to see all the errors so that I can fix them in one run.
So.. I am now +1 for this change, but you are the maintainer and if you want to have this code, I am ok with that.
Thanks again!
@@ -119,31 +134,46 @@ def look_for_intersphinx(self, name: str) -> Optional[str]: | |||
return self.obj.system.intersphinx.getLink(name) | |||
|
|||
def link_to(self, identifier: str, label: "Flattenable") -> Tag: | |||
# :Raises _EpydocLinker.LookupFailed: If the identifier cannot be resolved and self.strict is True. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe have this as docstrig instead of comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I remember. I did not do that not to override the docstirng inherited by ParsedDocstring
.
Since this an implementation detail because we're always using the _CachedEpydocLinker
, and I did not want to change the pretty well documented docstring that we already have for link_to
and link_xref
.
|
||
def link_xref(self, target: str, label: "Flattenable", lineno: int) -> Tag: | ||
# :Raises _EpydocLinker.LookupFailed: If the identifier cannot be resolved and self.strict is True. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have it as docstring?
pydoctor/model.py
Outdated
@property | ||
def docstringlinker(self) -> 'epydoc2stan.DocstringLinker': | ||
""" | ||
Returns an instance of L{epydoc2stan.DocstringLinker} suitable for resolving names | ||
in the context of the object scope. | ||
""" | ||
if self._linker is not None: | ||
return self._linker | ||
from pydoctor.epydoc2stan import _CachedEpydocLinker | ||
self._linker = _CachedEpydocLinker(self) | ||
return self._linker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better for a separate PR, but also add all this info in a code comment :)
We are talking about the same errors again and again for the summary table generation, not different errors. Just run
And you'll see what I mean. See #497 |
I've thought to give up this change and instead implement caching for summaries and docstring stan. But here's the deal: there is not way to simply ignore xref warnings when we call I'm unsure what's the best way forward. The class Please tell me what you think, ok I'm maintainer but I do want to fix issue this the right way. Thanks. |
Do you have comments @adiroiban ? |
I am not -1 on this. Thanks! Sorry... I didn't had time to look into pydoctor for twisted usage and why CI doesn't fail an warnings. |
Great, thanks! |
This PR tries to solve #497, it partially succeeds but we also need to cache the whole Documentable summary stan.
It does fixes #478