Skip to content
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

Version selector #2072

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

Version selector #2072

wants to merge 30 commits into from

Conversation

thisisnic
Copy link

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

@hadley
Copy link
Member

hadley commented May 3, 2022

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 😄

thisisnic added a commit to apache/arrow that referenced this pull request Dec 1, 2022
…14800)

For context, this overrides the default navbar HTML with a custom version which makes a single change - adding a span called "version" which the JS will override.  An identically-named span existed in the template used with Bootstrap 3, which is why no JavaScript changes were needed.  This approach is almost identical to that in this PR to the pkgdown package which implements the same thing: r-lib/pkgdown#2072 

I built this locally, and it appears to have successfully added the dropdown back in.

![image](https://user-images.githubusercontent.com/13715823/205083695-e718c7e5-1dc1-4742-9ce8-f773611b8ab7.png)


Authored-by: Nic Crane <thisisnic@gmail.com>
Signed-off-by: Nic Crane <thisisnic@gmail.com>
@MLopez-Ibanez
Copy link

Arrow ended up removing this: apache/arrow#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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants