You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add version dropdown (for other versions of the docs) #23
it releases on a version.json file that presumably would get updated automatically or manually during a release. It lists all the versions to go in the menu explicitly
this JSON file also lists all previous releases, and this is used to display alert banners for "old release" or "pre-release" at the top
Also, the code for this is currently in a scripts.html template that gets included in every page. I kind of think it might be better to move the version handling to a completely separate JS file that gets loaded in the scripts template. That way if there is ever a time when maintainers want to update the version handling somehow for all versions of the docs, there is just one JS file per docs version to swap out.
+1 for this. FWIW, spyder just released its docs with a modified version of this theme and it has a version template, javascript,css. I don't see how it determines the document versions to list, I think it is connected to the multidocs sphinx extension. That builds the docs for each version, which is not really portable.
Not sure if it is relevant but just FYI for Bokeh we update/publish a versions.json file as part of our release, that lists the versions that should appear in a menu, as well as specifies the current latest version (so banners get raised when viewing older or dev/rc versions)
At a bare minimum, it would be nice to have an easier place to hook in to add/set-up the version chooser. Right now I need to copy/override the entire navbar to inject the <li> and other elements. Happy to submit a PR if there's some agreement on what including even that would look like.
@dopplershift There's also #244 that discusses the sidebar injection portion of this; we did something like this in our downstream fork, but in a more limited fashion.
I don't see how it determines the document versions to list, I think it is connected to the multidocs sphinx extension.
Its based on the tags and branches in the repo (and can use the version and release in your conf.py for the URLs and/or UI names, among other things), with a customizable whitelist for each, so you can customize which get shown. In addition, we have automated build scripting we developed that generates redirects, a tag for the current branch, and automatic stable/latest-type names; this could either be reused, packaged or turned into a Sphinx extension, perhaps.
That builds the docs for each version, which is not really portable.
I'm not sure I follow, but would love to hear more about this. Thanks!
As far as I can tell, and correct me if I am wrong, the multidocs sphinx extension builds the docs for every version at every invocation. The workflow for NumPy is to build the release version of the docs off the release tag, and copy that into a github repo numpy/doc (that already contains prebuilt documentation for previous versions).
What about adding a new theme option version_switcher that would accept a list of url's and display names? This would make it pretty easy for downstream packages to simply implement in their conf.py theme options by just passing a list of url's and version display string.
Some things to consider from the examples above too:
everyone is putting the version switcher in different places. Should it be in the nav header, a sidebar, left/right, etc... Should the theme be somewhat opinionated here and just choose one?
Should a version switch be directly linked to the new version's index page? If I'm on page example.com/v2.3/feature/method1, Should the url be switched to: example.com/v1.2/feature/method1 instead of example.com/v1.2? (Spyder does the former, Bokeh does the latter)
@greglucas The problem with that approach is that old versions of docs have to be rebuilt in order to show newer versions in their chooser. That's why the common approach is to put a json file at the top level, where JavaScript within the built docs can read the information on all the available versions and dynamically populate the selector.
Good point! A similar method could easily be wrapped up in a <script> tag to inject the js. 'theme_version_switcher': '/path/to/versions.json'.
Thinking on the fly here though, I think you'd still need to rebuild all of the old docs once initially to inject that script? But, at least it would be a one-time event rather than for each new release as you bring up.
Now that #248 is merged we have access to html_sidebars. This means that it should be pretty straightforward for people to add the dropdown that @greglucassuggests above, probably with the modification that @dopplershift suggests to have a single source of truth for the versions.
As a start, perhaps @greglucas could make a PR that adds a template for a dropdown selector here:
and then add a configuration option to add it to the list of html_sidebars that is activated by default in this theme? (as well as documentation for how others could add it manually).
Then a next step could be to find a way to add it to the navbar as well, but it seems this would be a good first-step.
Is this still wanted? I can see two PR but they look stalled. I started to add a rough badge on SciPy and I am not sure if I should just wait for it to happen here or not. xref scipy/scipy#14132
Folks, I am looking at this right now... trying to collect and digest all the information (and different implementations) so I am able to provide good and useful feedback in the current open PRs.
You should expect some comments on those PRs soon.
I might also add some other general thoughts here as well as I am understanding things more deeply.
Thanks for your patience and for the contributions!!
I have closed the first implementation (#276 because I believe the other two PRs (#433 and #436) are more mature and able to be merged soon.
Particularly, after looking at all the implementations, I have requested some changes in #436 so we can merge that one ASAP and iterate on top of it.
If you @drammock or @ThuWangzw disagree on the proposed path forward, let us know!
Woo your doc is really nice @drammock 👍 If you have any feedback for SciPy I would be interested 😅
Where can I get the working copy of both versions and languages drop-down, please? Are the above the 3-4 files that are responsible for this functionality ?
Thanks @tupui. And sorry to continue this discussion on a closed PR. I have been struggling to implement versions and language in Sphinx Readthedocs theme with limited documentation. It would be great if I get some resources on this as I am new to Sphinx. I would still try the Version switcher documentation Tupui had shared.
Activity
jorisvandenbossche commentedon Oct 28, 2019
@bryevdv implemented this for bokeh in bokeh/bokeh#9330 (see https://docs.bokeh.org/en/dev/index.html), so we can port that back to the main theme.
bryevdv commentedon Oct 28, 2019
Just some notes about the Bokeh version:
it releases on a
version.jsonfile that presumably would get updated automatically or manually during a release. It lists all the versions to go in the menu explicitlythis JSON file also lists all previous releases, and this is used to display alert banners for "old release" or "pre-release" at the top
Also, the code for this is currently in a
scripts.htmltemplate that gets included in every page. I kind of think it might be better to move the version handling to a completely separate JS file that gets loaded in the scripts template. That way if there is ever a time when maintainers want to update the version handling somehow for all versions of the docs, there is just one JS file per docs version to swap out.mattip commentedon Sep 1, 2020
+1 for this. FWIW, spyder just released its docs with a modified version of this theme and it has a version template, javascript,css. I don't see how it determines the document versions to list, I think it is connected to the multidocs sphinx extension. That builds the docs for each version, which is not really portable.
choldgraf commentedon Sep 1, 2020
note that we're discussing this issue in #234 as well...not sure if that's a dupe or not
bryevdv commentedon Sep 1, 2020
Not sure if it is relevant but just FYI for Bokeh we update/publish a
versions.jsonfile as part of our release, that lists the versions that should appear in a menu, as well as specifies the current latest version (so banners get raised when viewing older or dev/rc versions)dopplershift commentedon Sep 1, 2020
At a bare minimum, it would be nice to have an easier place to hook in to add/set-up the version chooser. Right now I need to copy/override the entire navbar to inject the <li> and other elements. Happy to submit a PR if there's some agreement on what including even that would look like.
CAM-Gerlach commentedon Sep 8, 2020
@dopplershift There's also #244 that discusses the sidebar injection portion of this; we did something like this in our downstream fork, but in a more limited fashion.
Its based on the tags and branches in the repo (and can use the
versionandreleasein your conf.py for the URLs and/or UI names, among other things), with a customizable whitelist for each, so you can customize which get shown. In addition, we have automated build scripting we developed that generates redirects, a tag for the current branch, and automatic stable/latest-type names; this could either be reused, packaged or turned into a Sphinx extension, perhaps.I'm not sure I follow, but would love to hear more about this. Thanks!
mattip commentedon Sep 9, 2020
As far as I can tell, and correct me if I am wrong, the multidocs sphinx extension builds the docs for every version at every invocation. The workflow for NumPy is to build the release version of the docs off the release tag, and copy that into a github repo numpy/doc (that already contains prebuilt documentation for previous versions).
greglucas commentedon Sep 9, 2020
What about adding a new theme option
version_switcherthat would accept a list of url's and display names? This would make it pretty easy for downstream packages to simply implement in theirconf.pytheme options by just passing a list of url's and version display string.In
conf.py:Then this theme could add another nav-item to the nav menu to create the dropdown.
This renders as:
Some things to consider from the examples above too:
everyone is putting the version switcher in different places. Should it be in the nav header, a sidebar, left/right, etc... Should the theme be somewhat opinionated here and just choose one?
Should a version switch be directly linked to the new version's index page? If I'm on page
example.com/v2.3/feature/method1, Should the url be switched to:example.com/v1.2/feature/method1instead ofexample.com/v1.2? (Spyder does the former, Bokeh does the latter)dopplershift commentedon Sep 9, 2020
@greglucas The problem with that approach is that old versions of docs have to be rebuilt in order to show newer versions in their chooser. That's why the common approach is to put a json file at the top level, where JavaScript within the built docs can read the information on all the available versions and dynamically populate the selector.
greglucas commentedon Sep 9, 2020
Good point! A similar method could easily be wrapped up in a <script> tag to inject the js.
'theme_version_switcher': '/path/to/versions.json'.Thinking on the fly here though, I think you'd still need to rebuild all of the old docs once initially to inject that script? But, at least it would be a one-time event rather than for each new release as you bring up.
choldgraf commentedon Sep 26, 2020
Is there a sphinx package that does this? And if not, I think it could be pretty easy to add a little lightweight one that would:
html_sidebarsto identify a placeholder for the version switcherThis theme could then depend on that library to re-use the dropdown if it wanted something in the top-bar
choldgraf commentedon Oct 11, 2020
Now that #248 is merged we have access to
html_sidebars. This means that it should be pretty straightforward for people to add the dropdown that @greglucas suggests above, probably with the modification that @dopplershift suggests to have a single source of truth for the versions.As a start, perhaps @greglucas could make a PR that adds a template for a dropdown selector here:
https://github.com/pandas-dev/pydata-sphinx-theme/tree/master/pydata_sphinx_theme/_templates
and then add a configuration option to add it to the list of
html_sidebarsthat is activated by default in this theme? (as well as documentation for how others could add it manually).Then a next step could be to find a way to add it to the navbar as well, but it seems this would be a good first-step.
tupui commentedon Jul 18, 2021
Is this still wanted? I can see two PR but they look stalled. I started to add a rough badge on SciPy and I am not sure if I should just wait for it to happen here or not. xref scipy/scipy#14132
ThuWangzw commentedon Jul 19, 2021
I'm working on #360 to add a version switcher and a locale switcher. Here are some things I'm considering:
Vue
Python
15 remaining items
drammock commentedon Jul 20, 2021
ok, thanks for clarifying. I'll assume then that your new PR will be coming soon and I'll save any further feedback for that PR.
damianavila commentedon Nov 18, 2021
Folks, I am looking at this right now... trying to collect and digest all the information (and different implementations) so I am able to provide good and useful feedback in the current open PRs.
You should expect some comments on those PRs soon.
I might also add some other general thoughts here as well as I am understanding things more deeply.
Thanks for your patience and for the contributions!!
damianavila commentedon Nov 23, 2021
All,
I have closed the first implementation (#276 because I believe the other two PRs (#433 and #436) are more mature and able to be merged soon.
Particularly, after looking at all the implementations, I have requested some changes in #436 so we can merge that one ASAP and iterate on top of it.
If you @drammock or @ThuWangzw disagree on the proposed path forward, let us know!
Sachin-Suresh commentedon Aug 25, 2022
Where can I get the working copy of both versions and languages drop-down, please? Are the above the 3-4 files that are responsible for this functionality ?
tupui commentedon Aug 25, 2022
@Sachin-Suresh please have a look at the documentation https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/version-dropdown.html
drammock commentedon Aug 25, 2022
the expansion to cover both languages and versions was never implemented (yet).
Sachin-Suresh commentedon Aug 26, 2022
Thanks @tupui. And sorry to continue this discussion on a closed PR. I have been struggling to implement versions and language in Sphinx Readthedocs theme with limited documentation. It would be great if I get some resources on this as I am new to Sphinx. I would still try the Version switcher documentation Tupui had shared.
feat: publish versioned documentation at release time