Repository navigation
Docs: publish the guides as a GitHub Pages site with navigation and search, built with mdBook by cargo xtask docs - #623
Merged
Conversation
The README, the guides in docs/ and the changelog become a site with navigation and search, https://forgepkg.github.io/forge/, in the order docs/SUMMARY.md lists them; docs/book.toml configures mdBook. `cargo xtask docs` stages the pages into target/docs/src and builds the site into target/docs/book. The pages keep linking each other and the source tree relatively, as GitHub shows them; the staging rewrites a link to another page into that page of the site, and a link into the source tree into the file on GitHub. A link to a missing file or heading, and a Markdown file in docs/ that SUMMARY.md does not list, fail it. `cargo xtask docs --check` runs the staging alone, and CI's fmt job runs it for a change to the pages or the code they link. The Pages workflow deploys the site when a push to main changes a page, and builds it for a pull request that changes how it is built. Fixes #622 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJZvR2rkRxb7zr7fddM
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.
Fixes #622
What
The README, the guides in
docs/and the changelog become one site at https://forgepkg.github.io/forge/. It has a sidebar in three parts (Running Forge, Formats, CI and publishing), an outline of each page and full-text search. It is built with mdBook 0.5.4.docs/SUMMARY.mdlists the site's pages in order. The README is the start page and the changelog is the last page. Its links are relative todocs/, so the file also works as a table of contents on GitHub.docs/book.tomlconfigures mdBook: the site URL, the GitHub link, light and navy themes, no chapter numbers, and Rust snippets that can't be run.cargo xtask docs(xtask/src/docs.rs) stages the pages intotarget/docs/src, then runsmdbook buildintotarget/docs/book. The pages keep linking each other and the source tree relatively, as GitHub shows them, and the staging rewrites those links:../crates/…,../DEVELOPMENT.md,./LICENSE) goes to the file (blob/main) or directory (tree/main) on GitHub;docs/that SUMMARY.md doesn't list. All problems are reported at once.Anchors are made the way GitHub makes them. Links inside code spans and fenced blocks are left alone. The GitHub URL comes from the changelog's
[Unreleased]:link, throughchangelog::repo_url, which is nowpub(crate). As in the rest of xtask, there are no new dependencies.cargo xtask docs --checkruns only the staging and its checks, without mdBook. It is now a step of CI'sfmtjob.ci-changes.shaddsdocs,README.mdandCHANGELOG.mdto thechangeloggroup, so a docs-only pull request runsfmtand nothing else. A change to the Rust code also runsfmt, which catches a link broken by renaming a file..github/workflows/pages.ymlbuilds the site and deploys it:mainthat change a page, and on demand;book.toml,SUMMARY.md,docs.rs, the workflow), it only builds;actions/upload-pages-artifactv5.0.0 andactions/deploy-pagesv5.0.1, pinned by commit SHA like every action here, both released more than six weeks ago. mdBook comes from the already-pinnedtaiki-e/install-action, whose manifest has 0.5.4.Docs:
DEVELOPMENT.mdgets a Documentation site section and a line in the helper-command list, thextask helptext has the new command, and the README links the site.Before it can deploy
A repository administrator must set Settings → Pages → Source: GitHub Actions once; no tool available to this session can change that setting. Until then the
deployjob fails, and the first push tomainafter the setting deploys the site. Re-run all jobs on the workflow's last run deploys it right away.How it was checked
cargo test -p xtask: 31 + 1 tests pass, including six new ones (anchor names, repeated headings, code left alone, the staging of a small repository, every kind of broken link, path resolution).cargo fmt --all --checkandcargo clippy -p xtask --all-targets -- -D warningsare clean.cargo xtask docs --checkon the real pages: all 12 pages, every link resolves.cargo xtask changelog --checkandimage-pin-check.shpass, and both workflows parse.id, so mdBook names headings the way GitHub does. No.mdlink is left over, and 145 links go to GitHub. Screenshots of the start page, a guide and a search came out as expected.ci-changes.shwas tested on a probe commit that touches onlydocs/gitlab-ci.md:changelog=true, every other groupfalse.Not in this PR
mdBook warns about five placeholders written as raw tags:
**Admin → Users → <user>**and the like, indocs/deployment.md(3) andCHANGELOG.md(2). GitHub drops those tags as well, so the text already reads "Admin → Users →" today. Escaping them is a separate fix, andCHANGELOG.mdis not edited by changes.Changelog
docs/changes/2.1.1/622.docs.md, next to #618's fragment, under 2.1.1 for the same reason (there is no milestone for the next release yet).Generated by Claude Code