Add version selector to Docs#1356
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## docs-version-banner #1356 +/- ##
====================================================
Coverage 88.80% 88.80%
====================================================
Files 58 58
Lines 8516 8516
Branches 8516 8516
====================================================
Hits 7563 7563
Misses 640 640
Partials 313 313 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
1084f2a to
17d6346
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a documentation version selector widget (plus an updated version banner) by switching the mdBook theme/header.hbs snippet to a generated artefact, produced from a Jinja template and populated with the repo’s release tags.
Changes:
- Add a generated
theme/header.hbs(fromdocs/templates/header.hbs.jinja) that renders a version banner + version selector widget. - Remove the “Other versions of documentation” chapter and associated generation/redirect logic.
- Update the docs build workflow to generate the header snippet as part of the docs build recipes.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
theme/header.hbs |
Removes the previously committed header snippet (now generated). |
theme/.gitignore |
Ignores generated theme/header.hbs. |
docs/templates/header.hbs.jinja |
Adds the banner + version selector widget template and JS logic. |
docs/templates/versions.md.jinja |
Removes the template for the old “Other versions…” page. |
docs/SUMMARY.md |
Removes the “Other versions of documentation” entry from the TOC. |
docs/release/patches/v2.1.0/0001-Remove-other-versions-docs-from-contents.patch |
Ensures the v2.1.0 docs TOC also drops the removed chapter. |
docs/release/patches/v2.0.0/0002-Add-placeholder-other-versions-of-docs-chapter.patch |
Removes the patch that previously added the placeholder chapter to v2.0.0 docs. |
docs/generate_header.py |
Repurposes the generator script to render theme/header.hbs from the new template. |
docs/build_old_docs.py |
Removes the old versions.html redirect patching step. |
docs/.gitignore |
Stops ignoring versions.md since it is no longer generated. |
build-docs.just |
Replaces the old “versions” generator target with a new header generator target and wires it into all. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <div id="version-widget"> | ||
| <ul id="version-list" aria-label="Change version list" aria-haspopup="true"></ul> | ||
| <span id="version-label">docs: <span id="version-label-text"></span> <span id="version-arrow">▲</span></span> | ||
| </div> |
| if (v.label === currentVersion) { | ||
| li.innerHTML = "<strong>" + v.label + "</strong>"; | ||
| } else { |
| @uv run docs/generate_header.py | ||
|
|
||
| # Build documentation for previous releases | ||
| old: |
| padding: 6px 12px; | ||
| border-radius: 4px 4px 0 0; | ||
| cursor: default; | ||
| user-select: none; |
alexdewar
left a comment
There was a problem hiding this comment.
This looks great and I'm all for this approach. I suggest we merge this branch directly into main and close #1355.
I do think it would be better if we could avoid displaying the warning on the v2.1.0 page though, as it's a little confusing. I've made a suggestion -- let me know if you think it's workable.
| { label: "stable" }, | ||
| {%- for release in releases %} | ||
| { label: "{{ release }}" }, | ||
| {%- endfor %} |
There was a problem hiding this comment.
Instead of having a separate stable/ folder, I'm wondering if we can figure out which is the stable version on the frontend.
For example, maybe you could change the objects in versions to have separate label and path fields. After this jinja business, you could append (stable) to the label of the first release. We could not show the banner for anything with a label that contains stable. What do you think?
There was a problem hiding this comment.
Minor nit, but could we create the theme folder lazily and add theme/header.hbs to the main .gitignore file instead? That way we can avoid having another top-level folder
Description
This PR extends on #1355 by adding a version selector widget to the bottom right of the docs (inspired by the Django docs and the MUSE1 documentation).
The widget is built by adding HTML and CSS components to the
theme/header.hbswith some JS to dynamically determine which version of the docs we are currently in (just like the banner in #1355, this was LLM-assisted). But the list of versions needs to be generated dynamically, so this is achieved following the same pattern pre-existing in the documentation:headeroption in the justfile to run the scriptI also have removed the "Other versions of documentation" section of the docs. I believe this widget supersedes the need for that section, which was already a little buggy/confusing because it would always redirect to the development version of the docs.
Screenshots:



An extension on #1188
Assisted-by: Claude Sonnet 4.6
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks