Repository navigation
docs: inject the latest git tag into the tutorial snippets - #32
Merged
Merged
Conversation
The tutorial's copy-paste blocks pinned this project at a literal `<tag>` placeholder readers had to fix by hand. Replace those with a `__LATEST_TAG__` sentinel and add a build-only MyST transform (docs/_ext/inject-latest-tag.mjs) that swaps it for the repo's latest tag (`git describe --tags --abbrev=0`) at build time, so the rendered snippets carry a real, current ref. The tag comes from a LATEST_TAG env set by the `docs`/`docs-dev` npm scripts (which fetch tags first so it works in a shallow CI checkout); the transform falls back to `git describe` directly and warns rather than silently shipping the sentinel if no tag resolves. Scope: tutorial only; reference/architecture keep the literal `<tag>`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The shallow default clone has no tags, so a build-command deriving a version from `git describe` (this repo's docs, to pin the tutorial snippets at the latest release) found none in CI and fell back to the sentinel. Fetch full history + tags unconditionally; tags are cheap and any consumer's build-command can now rely on them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Now that docs.yml checks out with fetch-depth 0, the tags are always present in CI, so the LATEST_TAG env + the `latest-tag` npm helper (with its shallow-clone fetch fallback) are redundant. Drop them and let the transform call `git describe` directly; restore the plain `docs`/`docs-dev` scripts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The tutorial's copy-paste blocks pinned this project at a literal
<tag>placeholder readers had to fix by hand. This replaces them with a__LATEST_TAG__sentinel and adds a build-only MyST transform that swaps it for the repo's latest tag at build time, so the rendered snippets carry a real, current ref (v0.16.0today).How
docs/_ext/inject-latest-tag.mjs— adocument-stage MyST transform that replaces__LATEST_TAG__in text/code nodes. Build-only (never runs in the browser, unlikeversion-switcher.mjs), so it's free to touch git. Lives underdocs/_ext/, notplugins/, since it's docs tooling, not the shipped widget.package.json— alatest-tagscript (git describe --tags --abbrev=0, falling back togit fetch --tags && describefor the shallow CI checkout, which has no tags) feedsLATEST_TAGintodocs/docs-devvia aLATEST_TAG=… sh -c '…'wrapper so the env actually reachesmyst.docs/myst.yml— registers the plugin.docs/tutorials/adding-to-a-fresh-repo.md— the 4 copy-paste code blocks + the inline pin use__LATEST_TAG__; reworded the two prose lines that referenced the old placeholder.If no tag resolves, the transform leaves the sentinel and emits a build warning rather than silently shipping
__LATEST_TAG__.Scope & known limitation
reference/andexplanations/keep the literal<tag>.Verification
v0.16.0; no sentinel in the rendered HTML.npm test→ 22/22; biome clean; prek passes.🤖 Generated with Claude Code