pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

Version selector

Open thisisnic opened this issue 3 years ago • 3 comments

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.json in their package's pkgdown/assets directory, 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 to window.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

thisisnic avatar Apr 19 '22 15:04 thisisnic

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 😄

hadley avatar May 03 '22 19:05 hadley

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)

MLopez-Ibanez avatar Aug 07 '23 16:08 MLopez-Ibanez

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.

jayhesselberth avatar Jun 20 '24 12:06 jayhesselberth