Repository navigation
refactor(docs): unify AUTO-GENERATED marker form; share constants across crate boundary - #2418
Merged
Merged
Conversation
…oss crate boundary - Hoist `MARKER_OPEN_PREFIX` and `MARKER_CLOSE` into `src/docs.rs` so both `src/help.rs` (producer of the help-page region markers) and `tests/integration_tests/readme_sync.rs` (consumer + producer of snapshot markers) reference the same literal — drift between sides becomes a build error instead of a silent mismatch. - Drop the `-HTML` suffix variant. Both flavors emitted visually identical terminal-shortcode wrappers; the suffix only existed to disambiguate in-place-refreshable markers from fully-regenerated ones, but the `.snap` ID + terminal-shortcode body together are already specific enough for the refresh regex. - Route the help-page mirrored marker (`<!-- END AUTO-GENERATED from \`wt cmd --help-page\` -->`) through the shared constants. - Drop `MarkerType::output_format()` / `extract_inner()` — both had a single trivial non-panic branch existing only to enforce "no Snapshot in README". Replaced with one explicit assertion at the call site, which surfaces the invariant as an actionable error rather than a `unreachable!()` panic. - Collapse `format_replacement` so `wrap_in_marker` is invoked once for both output formats — only body construction varies. - `tests/integration_tests/user_hooks.rs:2320`: drop the `__WT_QUOT__` → `'` placeholder dance. The single quotes work fine inline (the outer raw-string literal already tolerates them, and TOML / Tera don't care about embedded `'`). Removes a name-conflation footgun with the unrelated `__WT_QUOT__` placeholder in `src/docs.rs`. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 25, 2026
7 tasks done
max-sixty
added a commit
that referenced
this pull request
Apr 26, 2026
…ot wrappers (#2419) ## Summary Two follow-ups from #2418 review. - **Test brittleness fix.** Three previously-separate sync tests had data dependencies that nextest could interleave: `test_readme_examples_are_in_sync` reads `docs/content/*.md`, which `test_docs_quickstart_examples_are_in_sync` generates from snapshots. Under parallelism, README sync could see stale docs and produce content that required a second run to converge. Collapsed both into the existing `test_command_pages_and_skill_files_are_in_sync` pipeline, renamed to `test_docs_are_in_sync`. Steps run sequentially in dependency order; single pass converges from a clean working tree. Each step's errors and updated-file list are tagged with the pipeline stage (`[command pages]`, `[standalone docs]`, `[README]`, etc.) so a failure tells a developer which stage broke without reading the test source. README failure also now reports `(N of M section(s) updated)`. - **Dead inner snapshot wrappers.** `expand_command_placeholders` wrapped each terminal shortcode in command pages with `<!--⚠️ AUTO-GENERATED from <snap> --> ... <!-- END AUTO-GENERATED -->` markers. Command pages regenerate wholesale from `--help-page` each sync, so the inner wrapper served no in-place-refresh purpose — it was dead weight nested inside the outer help-page region's markers. Stripped from `expand_command_placeholders`'s HTML branch; net -32 lines across six command-page docs files. The outer help-page region's mirrored close stays — it's load-bearing whenever any nested `AUTO-GENERATED` marker appears in the body. Comment in `src/help.rs:emit_footer` updated to explain the role. (My follow-up note that the mirrored close was redundant turned out to be a misanalysis — non-greedy `.*?` only safely pairs the open with the right close when there are no nested closes; once the inner snapshot wrappers were gone, the mirror became technically unnecessary, but keeping it survives any future reintroduction of nesting at no cost.) Renamed the test in `CLAUDE.md` (4 sites) and `docs/CLAUDE.md` (2 sites) so the documented `cargo test` invocations resolve. Net diff: −54 lines. ## Test plan - [x] `cargo test --test integration readme_sync` — 11 sync tests pass (was 13; minus the two collapsed) - [x] `cargo test --test integration` — full integration suite (1557 tests) pass - [x] **Single-pass convergence verified**: `git checkout docs/ README.md && cargo test --test integration test_docs_are_in_sync && git diff --stat` produces an empty diff after the first run - [x] Visual check via local Zola dev server: \`/worktrunk/\`, \`/llm-commits/\`, \`/claude-code/\`, \`/tips-patterns/\`, \`/merge/\`, \`/step/\`, \`/remove/\`, \`/hook/\`, \`/list/\` all render terminal blocks cleanly with no leaked marker strings - [x] Adversarial review of the consolidation (subagent /popper-style): all 4 actionable findings (stale doc references, lost README count, missing stage tags, etc.) addressed - [x] `cargo clippy --all-targets --all-features` — clean - [x] `cargo fmt --check` — clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
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.
Summary
Follow-ups from #2417 review, plus adjacent simplifications.
MARKER_OPEN_PREFIXandMARKER_CLOSEnow live insrc/docs.rs.src/help.rs(the--help-pageproducer of help-region markers) andtests/integration_tests/readme_sync.rs(the consumer + producer of snapshot/section markers) both reference them — drift becomes a build error rather than a silent mismatch.MARKER_OPEN_HTML_PREFIX. The-HTMLvariant emitted visually identical wrapping; the suffix only signalled "in-place refreshable" but the.snapID + terminal-shortcode body inDOCS_SNAPSHOT_MARKER_PATTERNalready discriminate that. Standardised on a single open prefix and stripped the-HTMLliterals fromREADME.md, the four standalone docs files, and the test file.<!-- END AUTO-GENERATED from \wt --help-page` -->) stays as-is because adjacent regions need unambiguous pairing, but the open prefix now goes throughMARKER_OPEN_PREFIX`.MarkerType::output_format()/extract_inner(). Both had a single trivial non-panic branch that existed only to enforce "no Snapshot markers in README" viaunreachable!(). Replaced with one explicit assertion insync_readme_markers— surfaces the invariant as an actionable error message instead of a panic.format_replacement.wrap_in_markeris invoked once for both output formats; only body construction varies.__WT_QUOT__rename intests/integration_tests/user_hooks.rs. Inlined the single quotes — the.replace('__WT_QUOT__', \"'\")was unnecessary indirection (the outer raw-string literal already tolerates', and TOML / Tera don't care about embedded'). Removes a name-conflation footgun with the unrelated__WT_QUOT__placeholder insrc/docs.rs.Net diff: -7 lines.
Test plan
cargo test --test integration— full integration suite (1559 tests) passcargo test --test integration readme_sync— all 13 sync tests pass;test_readme_examples_are_in_syncnow produces a stable README on a clean run (verified by re-running multiple times — no further updates after the initial regeneration)cargo test --test integration test_args_indexing_and_length_in_hook_template— confirms the user_hooks single-quote inlining works through TOML and TeraAUTO-GENERATED-HTML,__WT_OPEN2__, trailing|||)cargo clippy --all-targets --all-features— cleancargo fmt --check— clean🤖 Generated with Claude Code