-
Notifications
You must be signed in to change notification settings - Fork 317
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
Add version dropdown (for other versions of the docs) #23
Comments
@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. |
Just some notes about the Bokeh version:
Also, the code for this is currently in a |
+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. |
note that we're discussing this issue in #234 as well...not sure if that's a dupe or not |
Not sure if it is relevant but just FYI for Bokeh we update/publish a |
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.
Its based on the tags and branches in the repo (and can use the
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 In base_url = 'https://example.com/example/doc/'
version_choices = [
('latest', '2.1'),
('2.0.2', '2.0'),
('1.3.3', '1.3')]
version_choices = [base_url + v[0], v[1] for v in version_choices]
html_theme_options = {'theme_version_switcher': version_choices} 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:
|
@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. 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. |
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:
This theme could then depend on that library to re-use the dropdown if it wanted something in the top-bar |
Now that #248 is merged we have access to 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 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 |
Ok thanks I will wait for this to happen then. |
@ThuWangzw in case it's helpful, here is how we implemented the version switcher in this theme, in MNE-Python: |
Woo your doc is really nice @drammock 👍 If you have any feedback for SciPy I would be interested 😅 |
@drammock even better would be a PR or comments on an existing PR for this theme 🙃 |
Agreed! What I meant was more in terms of config with respect to this theme 😃 |
😆 it's on my TODO list, but I keep hoping someone else will beat me to it |
OK, I just re-read this whole thread, and can make an almost-concrete proposal, based on how we did this in MNE-Python:
|
That sounds quite nice to me 🙂 I guess the main question is whether one of the other PR implementations wishes to make a push as well so that toes don't get stepped on. That said, we have lots of not quite done implementations, so my vote is for whatever works and is in ready-to-merge condition 🙂 |
@drammock Thanks for your advice! 👍
|
@ThuWangzw I have a couple questions:
|
@drammock There is a situation that should be considered:
For example, if we click Python 3.9 doc, jump to Python 3.7 but can not find 3.9 in the dropdown menu. It's so strange. (Seems Python use switchers.js and python/docsbuild-scripts#91 to solve it. They have to maintain https://github.com/python/docsbuild-scripts/blob/main/build_docs.py and it needs several hours to build each version docs.) Although you can put a link to the So if we can put a @ThuWangzw is working on this branch now. @drammock We need more discussion and suggestions, anyone is welcome~ |
ah, good point @MegChai. that's a good reason to prefer
OK, I looked at that branch. Comments:
|
@drammock You are right. #360 will be closed. We planned to develop on Using |
That's a good reason why you should not open PRs from a
I've already acknowledged that using
I may be misunderstanding the situation, but it sounds like you might be taking the approach of implementing it the way that works best for you, and then opening a "take it or leave it" pull request for an implementation that you don't intend to change. There's nothing necessarily wrong with that --- sometimes your local needs are urgent and you can't wait for the upstream maintainers to all agree and for a new release to be made --- and it's still nice of you to offer your implementation back to upstream. But if that is the approach you are taking, it seems a little disingenuous to say things like "We need more discussion and suggestions, anyone is welcome". Those discussions and suggestions typically happen in open pull requests, which you've said you will open only after you've finished your implementation. This leaves an impression that you're not actually open to collaborative decision-making about how the implementation should look. In light of that, can you clarify your intentions? |
Sorry, I may not have explained clearly, we originally planned to update directly on the
This sentence seems to be me talking to myself, please ignore it... |
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. |
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. Thanks for your patience and for the contributions!! |
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. If you @drammock or @ThuWangzw disagree on the proposed path forward, let us know! |
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 ? |
@Sachin-Suresh please have a look at the documentation https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/version-dropdown.html |
the expansion to cover both languages and versions was never implemented (yet). |
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. |
We would like to have a version dropdown to switch to a different version of the docs.
Some examples:
Python docs (https://docs.python.org/3/) (also sphinx based, could look how they do it):
Docker docs (https://docs.docker.com/install/overview/):
Readthedocs theme also supports this (so this could also be worth a look how they do it):
The text was updated successfully, but these errors were encountered: