-
Notifications
You must be signed in to change notification settings - Fork 326
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
fix: resolve path of switcher when using relative #1344
Conversation
@12rambau I pushed a commit that makes this work for me locally. You can test it by setting json_url = "_static/switcher.json" in |
thanks for the help, but it's not going to work, the redirection trick I used need to be applied to fetch the json file, not to read the url (which is usually correctly formed in the json itself). I'll try to reshape your solution a bit. |
@drammock I updated your code and it's now working for me both locally and the PR build. What do you think ? |
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 think this is almost there. Switcher is now populated and functional on local builds with a relative path to JSON, and on RTD CI build with an absolute path. Wondering if we should add a test that uses relative-path JSON, and make sure things get populated correctly? (since we're normally not using relative path in our own docs, it seems too easy to introduce a regression).
There is still a problem with the "link to corresponding page" vs "link to homepage" functionality. (Example is that from the user guide page on CI build clicking latest
gets you to homepage of latest, not user-guide page of latest. This is probably because .cloneNode
wipes out onclick
attributes, so the onclick needs to be added after cloning. I can push a commit testing that shortly.
I'm not sure a test is necessary here as we use a relative link for every PR/latest. as long as we at least try to display the button we will see the cullprit. |
really? Our |
yep the json url is switched if you are in a PR build with a "dev" version to a relative path: pydata-sphinx-theme/docs/conf.py Line 113 in 347a592
that's why I was working on it initially, to make it work in PRs. |
Ha OK sorry I didn't realize that before. So no new test needed.
I didn't manage to fix this by just putting |
Fix #647
check if the json file is relative, if it's the case I'm creating a dynamic absolute path from the root of the current website, making the documentation work in dev mode.