-
Notifications
You must be signed in to change notification settings - Fork 71
Changes for multi-version docs #668
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
base: main
Are you sure you want to change the base?
Changes for multi-version docs #668
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #668 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 34 34
Lines 1981 1981
=========================================
Hits 1981 1981 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Thanks @animeshsasan.
Please read the following in the context of my review of neuroinformatics-unit/actions#93.
Because of the mentioned change in URLs, some links to specific documentation pages need to be updated in this repo's README, e.g. links to installation instructions and examples. You won'd need to update the main website link itself, i.e. movement.neuroinformatics.dev
— if you take my advice about a redirect. You also need not worry about internal links in the website, as those rely on sphinx cross-references instead of URLs, and should be robust to the change.
The slightly bigger issue is with binder, which we use in combination with sphinx-gallery to allow our examples to run on binder instances on the web. See docs on sphinx-gallery + binder configuration. If you look higher in the conf.py
file you'll see that binder pulls the examples from the gh-pages
branch, which currently has an "examples" folder in the root. Now that folder will be under "latest/examples", so I'm worried that the binder integration may break. I'm not sure how to test this exactly, unless we also add some sphinx-gallery examples on the fork. Could you investigate this and see whether we'll have problem with that?
Note that NeuroBlueprint doesn't include sphnx-gallery examples, so that was never an issue.
I’ve updated the links in the README to include the /latest part of the URL. To verify how the documentation build would look, I built and deployed the docs on my fork here. From what I found: So it seems this restructuring should not cause any issues. You can view the deployed documentation here: example page. One thing I did notice while testing: the Binder link fails to launch for the docs deployed from the main repo as well. I might be missing something, but if Binder is indeed broken there, we may need to fix that separately. |
I also wanted to check whether we should clean up the existing gh-pages branch before merging this PR. Technically it shouldn’t cause any issues since the current changes overwrite the index.html to redirect to /latest, but I thought I’d confirm with you first. |
That was working fine a few days ago (we tested it after the latest release and nothing changed since then). According to the error message, the problem is with BinderHub itself which is too busy at the moment. Similar issues have cropped up in the past. That said, I was able to make it work after a few tries, but we probably have to wait a bit for BinderHub to quiet down.
I was actually able to run the examples from your fork on Binder! Thanks for making a fork and deploying a website from there, it was super useful to verify functionality. |
I'm a bit wary of doing this right away, as it will potentially take down our website. My current tentative plan is do the following:
What do you think? |
Testing on NeuroBlueprint first turned out to be a good idea. We discovered some hiccups in the process:
Apart from the above issues, which are now patched, there is one remaining snug: if you look at the version switcher dropdown at https://neuroblueprint.neuroinformatics.dev/latest/index.html, it displays "Choose version" no matter which version we've selected (I belatedly realised this is also the case on your forked website test). The expected behaviour is for the currently selected version to be displayed there, as is the case for the NumPy docs website: https://numpy.org/doc/1.26/index.html Could you look into it? |
Hey @niksirbi, Regarding the second issue, I want to clarify my understanding: in the new changes, we’re updating the switcher.json in the dev build to match the one in latest. Since the live website always fetches the switcher.json from /latest, I wasn’t clear why the contents of the dev file itself would matter. Even when we sync the content, we’re just copying from /latest, so an older switcher.json in dev shouldn’t have an effect, unless there’s a subtle detail I’m missing. Could you clarify that part? As for the problem with the version not being displayed in the switcher dropdown: I’ve tracked this down. The version shown in the switcher is determined by the value of html_theme_options["switcher"]["version_match"]. This value is compared against the version fields in the switcher.json, and if they match, the corresponding version label is displayed. The bug is that our version_match was just I also suspect something similar has been happening in the NeuroBlueprint docs. For example, v0.3.0 shows up correctly in the switcher when selected, but newer versions do not. That suggests there may have been a change in how version_match was being set at some point. One more detail: if version_match is supplied with an incorrect value, the switcher will fall back to whatever value is supplied in version_match. For instance, in my test docs the logo text (which uses the same variable) shows v0.1.14 even when browsing v0.1.15 or v0.1.16. The switcher itself will still let you navigate, but the displayed label comes directly from the mismatched version_match. |
Re neuroinformatics-unit/actions#103, your interpretation is correct in that the dropdown always uses the |
It was indeed a red herring, but I'd stick with the current form of the action anyway. It makes more conceptual sense for the
That seems correct to me and would be an easy fix. But if you are right we'd still have the problem for the |
Makes sense! I agree it’s still useful to keep the changes and having the switcher.json consistent between dev and latest helps with clarity, and there’s no downside. For the version-matching issue, I think a small transformation in conf.py should cover the edge cases. Something like:
I am new to setuptools_scm, but from what I understand about how it works, the cases break down like this:
The if check should normalize all of these into either "dev" or "vX.Y.Z", which then lines up with the entries in switcher.json. In the rare case of a LookupError, Sphinx would fall back to showing Do you think there are other setuptools_scm version formats or special cases we’d need to handle, or would this be sufficient? Some context from my fork:
This command only returns the most recent tag (e.g. 0.1.16) and strips the leading v. That’s what’s causing the mismatch for both the Development build and for older tagged versions like v0.1.15 and v0.1.16(I just created a new tag and pushed in the later cases without a commit). This should not happen with setuptools_scm since it always returns the latest tag. |
You may go ahead with implementing it as shown in your snippet @animeshsasan. |
@animeshsasan I applied your suggested fix to NeuroBlueprint, and made a new [
{
"version": "dev",
"url": "https://neuroblueprint.neuroinformatics.dev/dev/"
},
{
"name": "v0.4.0 (latest)",
"version": "v0.4.0",
"url": "https://neuroblueprint.neuroinformatics.dev/latest/latest"
},
{
"version": "v0.3.3",
"url": "https://neuroblueprint.neuroinformatics.dev/latest/v0.3.3"
},
{
"version": "v0.3.2",
"url": "https://neuroblueprint.neuroinformatics.dev/v0.3.2"
},
{
"version": "v0.3.1",
"url": "https://neuroblueprint.neuroinformatics.dev/v0.3.1"
},
{
"version": "v0.3.0",
"url": "https://neuroblueprint.neuroinformatics.dev/v0.3.0"
}
] As you can see the URLs for both the latest (
|
The problem actually comes from this line of the action BASE_URL="$(jq -r '.[1].url|split("/")[0:-1]|join("/")' <<< $SWITCHER_CONTENT)" which is supposed to remove the last element of the URL (after the last slash). This is not robust to trailing slashes, and one such trailing slash was present in the URL of version This edge case arose specifically in NeurBlueprint, because our previous hacky workflow was appending An easy fix would be to strip any trailing slashes first, then remove the # Derive a stable BASE_URL even if the switcher has trailing slashes
BASE_URL="$(jq -r '.[1].url
| sub("/+$"; "") # drop trailing slash(es)
| sub("/latest$"; "")' <<< "$SWITCHER_CONTENT")"
NEW_URL="${BASE_URL}/latest" |
Note that for the NeuroBlueprint case, I've patched things up by directly pushing the fix to the gh-pages branch (bad practice, I know). This completely fixed the None of this should be a problem for future versions of NeuroBlueprint, or any other package like
|
|
I’ve updated the current PR to include the if condition you suggested, replacing the release variable with doc_version for the version_matcher. Great catch, @niksirbi ! You’re right, this likely wouldn’t cause problems for repos adopting multi-version docs for the first time through our action, but as you pointed out, projects like NeuroBlueprint that already have a switcher.json in place can definitely run into this edge case. To address this, I’ve opened a PR with the proposed fix here: neuroinformatics-unit/actions#105. Thanks again for flagging this! |
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'm approving this PR as good-to-go now, thanks @animeshsasan 🎉 .
I'll merge it shortly before the next release and set aside some time to deal with anything we might have missed (though I'm now reasonably confident that we've caught all edge cases).
Description
What is this PR
Why is this PR needed?
This PR is the implementation for neuroinformatics-unit/actions#91.
At present, our build_sphinx_docs and deploy_sphinx_docs actions only deploy a single version of the documentation (either from main or the latest release) to GitHub Pages. In brief:
build_sphinx_docs builds the Sphinx docs and uploads an artefact
deploy_sphinx_docs downloads the artefact and copies it to the root of the gh-pages branch
This means users and contributors cannot view older versions of the docs, except by checking out an old commit and building locally. Having access to documentation for previous releases would be extremely useful.
What does this PR do?
The PR adds the version switcher to the docs along with changing the document deployment step to the newly created multiversion deploy step.
References
A similar implementation is used in the NeuroBlueprint repository here.
Please reference any existing issues/PRs that relate to this PR.
How has this PR been tested?
A test implementation exists by forking this repository and making changes to enable the multi-version switcher. You can see it in action here.
Is this a breaking change?
The document deploy step is changing but no actual features are changed.
Does this PR require an update to the documentation?
It requires updating the movement repository to create the multi-version dropdown but no actual documentation has changed.
Checklist:
Tests have been added to cover all new functionality(I don't think there are any tests for the docs)The documentation has been updated to reflect any changes