Enable switching different versions of documentation#621
Conversation
How to test this PR: ``` git checkout doc-switcher cd doc make cd .. git checkout gh-pages rm -r dev cp -r doc/_build/html dev python -m http.server ```
weiji14
left a comment
There was a problem hiding this comment.
Awesome comprehensive writeup! Managed to go through the step by step instructions and got this working locally in no time. Only two minor nitpick comments (which you can ignore), otherwise let's get this handy feature merged in (after changing "0.0.0.0:8000" to "www.pygmt.org" of course)!
|
|
||
| <!-- Documentation switcher --> | ||
| <!-- Point to the *dev* version switcher. This will allow the latest versions to appear on older documentation. --> | ||
| <script type="text/javascript" src="/dev/_static/version_switch.js"></script> |
There was a problem hiding this comment.
I'm not a frontend/javascript expert, and I don't expect you to work on this. But, just pointing out that the dropdown isn't super-accessible. I managed to tab-tab-tab my way to the version changer dropdown (with the benefit of sight), and change to a different version of the documentation by pressing up/down with my arrow keys (only once though, it doesn't seem to allow scrolling through the list of options).
Guess my point here is that we should keep the section at https://www.pygmt.org/v0.2.0/index.html#documentation-for-other-versions for now just for a11y reasons, until we get a good developer that knows this stuff.
There was a problem hiding this comment.
Let's open an issue and see if someone with good web knowledge can help us.
There was a problem hiding this comment.
The changes are online now, and you can try it at https://www.pygmt.org.
There was a problem hiding this comment.
Yay 🎉! I see you've made the change directly at ae2aee5. Good work 👍
Description of proposed changes
Enable switching different versions of documentation. Adapted from GenericMappingTools/gmt#4110.
Preview:
How to preview/test this PR locally:
You will see that you can switch from
devto other versions, but can't swich back. That's because the old documentations are static HTML files, and don't include theversion_switch.jsscript.To enable switching back and forth, we need to manually add the following line in the HTML head part.
This can be done by running the following command in each subdirectory (e.g., in
v0.2.0)note: the sed command only work for the GNU
sed. For macOS users, rungsedinstead.TODO before merging this PR
doc_urlfrom0.0.0.0:8000(for local testing) towww.pygmt.orgTODO after merging this PR
_static/documentation_options.jsfile. It contains basic settings of the documentation. For old documentations, theVERSIONsetting is empty, because we didn't set thereleasevariable inconf.py. It will shows the weirdlatest ()instead oflatest (v0.2.0). We need to manually update the files of all old versions.Fixes #609.
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.