build(docs): gitignore generated docs/book/theme/lang-switcher.js#6395
build(docs): gitignore generated docs/book/theme/lang-switcher.js#6395singlerider wants to merge 1 commit intozeroclaw-labs:masterfrom
Conversation
`xtask::inject_lang_switcher_locales` rewrites this file's LOCALES array on every `cargo mdbook build` from locales.toml. Tracking it in git means anyone who builds docs locally ends up with a modified working tree, and `git add -A` then sweeps it into unrelated commits. Recent PRs have repeatedly carried accidental reorders of this file for exactly that reason. Untrack the file and add it to .gitignore. The xtask injector still emits it before mdbook runs, so the build artifact is unchanged.
36d11b3 to
ebf755b
Compare
Audacity88
left a comment
There was a problem hiding this comment.
Reviewed current PR head ebf755b. I checked the PR body, labels, CI, comments/reviews, the diff, docs/book/book.toml, xtask/src/cmd/mdbook/build.rs, and a clean scratch checkout of this PR. CI is green and I did not find any prior reviews or review comments.
🟢 Good direction — generated docs churn should not be source of truth
The goal makes sense. lang-switcher.js is partly generated from locales.toml, so removing accidental locale-order churn from unrelated PRs is a useful cleanup.
🔴 Blocking — clean docs builds fail without the tracked JS file
In a clean checkout of this PR head, docs/book/theme/lang-switcher.js is absent from the tree, but docs/book/book.toml still lists it in additional-js. The mdBook build then fails before producing docs:
ERROR Rendering failed ... failed to open 'theme/lang-switcher.js' for hashing ... No such file or directory
The xtask injector does not create the file when it is missing; inject_lang_switcher_locales() returns early if theme/lang-switcher.js does not exist. That means the validation can pass only if an ignored local copy is already present from an earlier build, while a clean clone / docs deploy path still breaks.
Could you keep a tracked template/source file, generate the full lang-switcher.js before mdBook runs, or split this into a tracked source template plus ignored generated output so clean checkouts still have the asset mdBook requires?
Summary
master(all contributions)xtask::inject_lang_switcher_localesrewritesdocs/book/theme/lang-switcher.json everycargo mdbook build. Because the file was tracked, any local docs build dirtied the working tree.git add -Athen swept it into unrelated commits — several recent PRs carried accidental LOCALES reorders for exactly this reason. This PR removes the file from the index and adds it to.gitignorealongside the other generated docs artifacts.locales.toml, or any mdBook build behavior. The file is still emitted at build time; it is simply no longer tracked.lang-switcher.jsis a build artifact. Consumers of the docs build are unaffected.Validation Evidence (required)
cargo mdbook buildstill regenerates it correctly fromlocales.toml.cargo fmt,cargo clippy,cargo test— docs-only change (.gitignoreentry +git rm --cached). Replaced with docs quality gate per template guidance.Security & Privacy Impact (required)
Compatibility (required)
Rollback (required for
risk: mediumandrisk: high)git revert <merge-sha>re-tracks the file. The xtask injector will overwrite it on the nextcargo mdbook buildregardless.