ENH: Add version switcher dropdown menu #276
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the start of adding a version dropdown selector as discussed in #23. I don't have a lot of time to work on this now, so if someone wants to borrow any of this or extend it, please feel free to.
I'm not entirely clear what the end goal is here. From what I can see, most people either roll their own javascript that does some form of regular expression parsing of the version numbers or use the built-in readthedocs version switcher that they provide (this hosted theme site already uses that). Do we want to force people into a standard within this theme, or do we want to be really flexible and allow many different url formats, version formats, etc...?
Here is a list of what this has so far:
The HTML buttons have a good look/feel, but the javascript needs some work. I also don't know how to pass sphinx theme options into the javascript utility functions, is there a good way to do that? This would make it easy to allow each project to define their own regular expressions for version finding without needing to directly modify the javascript included here.
CPython also has their versions hardcoded in the included js, not a separate versions.json file.
https://github.com/python/cpython/blob/master/Doc/tools/static/switchers.js
They also have a language selector that would be a good extension in a separate PR.