Skip to content

build(docs): gitignore generated docs/book/theme/lang-switcher.js#6395

Open
singlerider wants to merge 1 commit intozeroclaw-labs:masterfrom
singlerider:fix/lang-switcher-stale-generator-claim
Open

build(docs): gitignore generated docs/book/theme/lang-switcher.js#6395
singlerider wants to merge 1 commit intozeroclaw-labs:masterfrom
singlerider:fix/lang-switcher-stale-generator-claim

Conversation

@singlerider
Copy link
Copy Markdown
Collaborator

@singlerider singlerider commented May 5, 2026

Summary

  • Base branch: master (all contributions)
  • What changed and why: xtask::inject_lang_switcher_locales rewrites docs/book/theme/lang-switcher.js on every cargo mdbook build. Because the file was tracked, any local docs build dirtied the working tree. git add -A then 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 .gitignore alongside the other generated docs artifacts.
  • Scope boundary: Does not change the xtask injector, locales.toml, or any mdBook build behavior. The file is still emitted at build time; it is simply no longer tracked.
  • Blast radius: None. lang-switcher.js is a build artifact. Consumers of the docs build are unaffected.
  • Linked issue(s): N/A

Validation Evidence (required)

  • Commands run and tail output:
git ls-files docs/book/theme/lang-switcher.js
# (empty — file is no longer tracked)

git check-ignore -v docs/book/theme/lang-switcher.js
# .gitignore:9:docs/book/theme/lang-switcher.js

cargo mdbook build
# lang-switcher.js emitted by xtask injector, build completes normally
  • Beyond CI — what did you manually verify? Confirmed the file is untracked post-merge and that cargo mdbook build still regenerates it correctly from locales.toml.
  • If any command was intentionally skipped, why: cargo fmt, cargo clippy, cargo test — docs-only change (.gitignore entry + git rm --cached). Replaced with docs quality gate per template guidance.

Security & Privacy Impact (required)

  • New permissions, capabilities, or file system access scope? No
  • New external network calls? No
  • Secrets / tokens / credentials handling changed? No
  • PII, real identities, or personal data in diff, tests, fixtures, or docs? No

Compatibility (required)

  • Backward compatible? Yes
  • Config / env / CLI surface changed? No

Rollback (required for risk: medium and risk: high)

git revert <merge-sha> re-tracks the file. The xtask injector will overwrite it on the next cargo mdbook build regardless.

@singlerider singlerider added this to the v0.7.5 milestone May 5, 2026
@github-actions github-actions Bot added the docs Auto scope: docs/markdown/template files changed. label May 5, 2026
@singlerider singlerider marked this pull request as draft May 5, 2026 06:40
`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.
@singlerider singlerider force-pushed the fix/lang-switcher-stale-generator-claim branch from 36d11b3 to ebf755b Compare May 5, 2026 06:45
@singlerider singlerider changed the title docs(book): correct lang-switcher LOCALES comment + reorder to match locales.toml build(docs): gitignore generated docs/book/theme/lang-switcher.js May 5, 2026
@singlerider singlerider marked this pull request as ready for review May 5, 2026 06:45
@singlerider singlerider requested a review from Audacity88 May 5, 2026 06:46
@Audacity88 Audacity88 added risk: low Auto risk: docs/chore-only paths. size: S Auto size: 81-250 non-doc changed lines. labels May 5, 2026
Copy link
Copy Markdown
Collaborator

@Audacity88 Audacity88 left a comment

Choose a reason for hiding this comment

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

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?

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

Labels

docs Auto scope: docs/markdown/template files changed. risk: low Auto risk: docs/chore-only paths. size: S Auto size: 81-250 non-doc changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants