Skip to content

Add version selector to Docs#1356

Open
AdrianDAlessandro wants to merge 5 commits into
docs-version-bannerfrom
docs-version-selector
Open

Add version selector to Docs#1356
AdrianDAlessandro wants to merge 5 commits into
docs-version-bannerfrom
docs-version-selector

Conversation

@AdrianDAlessandro

Copy link
Copy Markdown
Collaborator

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.hbs with 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:

  1. Define a jinja template for the header file
  2. Write a script to turn that script into the required file
  3. Make git ignore the generated file
  4. Include a header option in the justfile to run the script

I 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:
Screenshot 2026-06-17 at 17 37 24
Screenshot 2026-06-17 at 17 37 49
Screenshot 2026-06-17 at 17 37 38

An extension on #1188

Assisted-by: Claude Sonnet 4.6

Type of change

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc
  • Update release notes for the latest release if this PR adds a new feature or fixes a bug
    present in the previous release

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@AdrianDAlessandro AdrianDAlessandro moved this to 👀 In review in MUSE Jun 17, 2026
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.80%. Comparing base (18a7683) to head (e1f950e).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (from docs/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.

Comment on lines +82 to +85
<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">&#x25b2;</span></span>
</div>
Comment on lines +133 to +135
if (v.label === currentVersion) {
li.innerHTML = "<strong>" + v.label + "</strong>";
} else {
Comment thread build-docs.just
@uv run docs/generate_header.py

# Build documentation for previous releases
old:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Copilot's right here

Comment on lines +40 to +43
padding: 6px 12px;
border-radius: 4px 4px 0 0;
cursor: default;
user-select: none;

@alexdewar alexdewar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 %}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread theme/.gitignore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

3 participants