Skip to content

feat(docs): implement documentation versioning#469

Open
lukapeschke wants to merge 5 commits intomainfrom
docs-versioning
Open

feat(docs): implement documentation versioning#469
lukapeschke wants to merge 5 commits intomainfrom
docs-versioning

Conversation

@lukapeschke
Copy link
Copy Markdown
Collaborator

closes #179

closes #179

Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com>
@lukapeschke lukapeschke requested a review from PrettyWood April 1, 2026 13:53
@lukapeschke lukapeschke self-assigned this Apr 1, 2026
@lukapeschke lukapeschke added documentation Improvements or additions to documentation enhancement New feature or request ✋ need review ✋ github_actions Pull requests that update GitHub Actions code labels Apr 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements versioned documentation builds (à la ReadTheDocs) so users can browse docs per release tag and switch versions from within the generated pdoc pages.

Changes:

  • Add a script to maintain docs/versions.json and generate a redirecting docs/index.html.
  • Update Makefile targets to build latest docs and versioned docs using a custom pdoc template.
  • Update the docs GitHub Actions workflow to build on main, tags, and manual dispatch, and publish versioned artifacts to gh-pages.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
scripts/update_versions.py New helper to update versions.json and generate the redirect page used as the docs entrypoint.
Makefile Builds docs into docs/latest and adds a doc-versioned target for CI/tag builds.
doc-templates/module.html.jinja2 Adds a client-side version switcher that reads versions.json and rewrites the current page URL across versions.
.github/workflows/docs.yml Builds docs on main/tags/dispatch and deploys per-version outputs to gh-pages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/docs.yml
Comment on lines +41 to +46
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "version=${{ github.event.inputs.version_tag }}" >> "$GITHUB_OUTPUT"
echo "is_stable=true" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
echo "is_stable=true" >> "$GITHUB_OUTPUT"
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The workflow currently sets is_stable=true for any tag build and for all workflow_dispatch runs. That means building docs for an older tag (or manually dispatching a build for an older version) will flip the “stable” redirect and version label to that older version. Consider making “mark as stable” an explicit workflow_dispatch input (default false) and/or only setting --stable when the tag is the highest semver release (or when the release is published).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread Makefile
cargo doc --no-deps --lib -p fastexcel --features polars

.PHONY: doc-versioned ## Build versioned documentation (CI usage: VERSION=v0.19.0 make doc-versioned)
doc-versioned: build-dev
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

doc-versioned relies on $(VERSION) but doesn’t fail fast when it’s unset. Running make doc-versioned without VERSION=... will write to docs/ and add an entry with an empty path to versions.json. Add a guard (e.g., ifndef VERSION -> error) or provide a sensible default.

Suggested change
doc-versioned: build-dev
doc-versioned: build-dev
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION is not set. Usage: VERSION=v0.19.0 make doc-versioned"; \
exit 1; \
fi

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines +27 to +31
var idx = window.location.pathname.indexOf(currentVersion);
var baseUrl = window.location.pathname.substring(0, idx);
// Get the page path after the version segment
var pagePath = window.location.pathname.substring(idx + currentVersion.length);

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The computed pagePath only uses window.location.pathname, so switching versions drops the current query string and hash (anchor), which is especially noticeable when linking to sections within the docs. Consider including window.location.search and window.location.hash when constructing the target URL so navigation preserves anchors.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines +73 to +77
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=./{redirect_path}/fastexcel.html"/>
</head>
<body>
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

redirect_path is interpolated directly into generated HTML attributes (meta refresh and <a href=...>). Since --version can come from a workflow_dispatch input, a malformed value can break the redirect page (and potentially inject markup). Consider validating version/redirect_path against an allowlist like latest or ^v\d+(\.\d+)*$ before writing index.html, and erroring out with a clear message if it doesn’t match.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread .github/workflows/docs.yml Outdated
@lukapeschke
Copy link
Copy Markdown
Collaborator Author

@PrettyWood could you please have a second look ?

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

Labels

documentation Improvements or additions to documentation enhancement New feature or request github_actions Pull requests that update GitHub Actions code ✋ need review ✋

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation versioning

2 participants