-
Notifications
You must be signed in to change notification settings - Fork 207
Back-reference optimizations #272
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
Conversation
if full_name in self._searchindex['objects']: | ||
value = self._searchindex['objects'][full_name] | ||
if isinstance(value, dict): | ||
value = value[next(iter(value.keys()))] |
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.
Note that this is completely wrong. For example, in plot_gallery_version
, np.random.random
is linked to np.random.lognormal
. I believe this is also in part due to #273.
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.
I just tested this PR. but in this case it does not even recognize np.random.random
I'll see with #273
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.
Definitely should be because of #273.
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.
This looks good. Thank you for doing this. I would love to have a test for the _get_link
, not sure how to do it yet.
else: | ||
value = int(value) | ||
|
||
docopts[key] = value |
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 you make a test for this function. Or at least move the parse to a separate function and then test that part at least.
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.
Test added, but this parsing is a separate function already?
sphinx_gallery/docs_resolv.py
Outdated
@@ -30,6 +30,9 @@ | |||
|
|||
from io import StringIO | |||
|
|||
from sphinx.search import js_index | |||
from sphinx.util import jsdump |
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.
This is not used
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.
Removed.
if full_name in self._searchindex['objects']: | ||
value = self._searchindex['objects'][full_name] | ||
if isinstance(value, dict): | ||
value = value[next(iter(value.keys()))] |
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.
I just tested this PR. but in this case it does not even recognize np.random.random
I'll see with #273
else: | ||
value = int(value) | ||
|
||
docopts[key] = value |
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 you provide a test for this function. Or at least move this parse to an independent function an test that part at least.
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.
+1 for tests
this sounds like a great addition, thanks @QuLogic ... I don't have a ton of experience w/ intersphinx code but I agree that it'd be good to test any new parsing functionality built in here. |
just a ping that #273 is merged now! |
This works well on my machine. I relaunched Circle CI, but it did not make the build on top of master to include #273, so I could not check on the other versions. |
On my OSX machine, on current |
This removes a lot of fragile manual parsing that is already maintained elsewhere.
There are only two callers and neither use these options.
This uses the data in the search index exactly as the JavaScript code does, meaning there's no need to search through the HTML of the page to check for the anchor.
Otherwise, it's very vague what URL is failing.
Rebased and |
Merged. Thanks @QuLogic |
Finding back-references involves downloading a file for every possibly used object in order to do two things:
All this downloading makes back-referencing slow, so instead:
DOCUMENTATION_OPTIONS
and find theFILE_SUFFIX
from there. If it's not defined, it's a really old Sphinx so assume.rst.html
.With these two changes, we can stop downloading all those files and just download 2 per back-reference URL. Additionally, use Sphinx's built-in parser to cut down on the parsing code.