Version selector
Initial PR implementing functionality similar to that mentioned in #1373
Deployed here: https://625ecfe71b4b2d1ec74155ac--rococo-beijinho-f54560.netlify.app/
Overview of changes:
- If a user supplies a file
versions.jsonin their package'spkgdown/assetsdirectory, when the site it built, some JS will be included which overrides the "version" span in the navbar and replaces it with a dropdown where they can choose which version of the documentation to browse - In
versions.json, the user can specify an array of JSON objects containing 3 fields: "label" (the label to display in the dropdown), "version" (the package version"), and "path" (the path at which the docs for this version are displayed, relative towindow.location.origin - You can see the setup for the version I used to test it at in
tests/testthat/assets/version-dropdown/README.md
Not implemented:
- I'd wanted to implement a feature I'd implemented in the Arrow pkgdown site where we can navigate from a subpage to another version's version of that subpage, but it depends on the fact that the Arrow site is deployed to some very specific paths which I use regex to parse, so I don't think I can implement this in a generalisable way here
Thanks for working on this! It'll probably be a while before I get a chance to understand this thoroughly, but the overall approach looks super simple, which is great 😄
Arrow ended up removing this: https://github.com/apache/arrow/pull/35103 I still believe it is a nice feature of Sphinx that pkgdown is missing: https://numpy.org/doc/stable/index.html
(But having developed a new Python package recently, I must say that the packaging ecosystem in Python is terribly painful compared to R)
I think a simpler approach would be to add version information into the main _pkgdown.yml as a separate section rather than use a separate json file.