Skip to content

refactor(docs): unify AUTO-GENERATED marker form; share constants across crate boundary - #2418

Merged
max-sixty merged 1 commit into
mainfrom
docs/static-output-for-gif-pages
Apr 25, 2026
Merged

max-sixty merged 1 commit into
mainfrom
docs/static-output-for-gif-pages

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Follow-ups from #2417 review, plus adjacent simplifications.

  • Cross-crate share of marker constants. MARKER_OPEN_PREFIX and MARKER_CLOSE now live in src/docs.rs. src/help.rs (the --help-page producer of help-region markers) and tests/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.
  • Drop MARKER_OPEN_HTML_PREFIX. The -HTML variant emitted visually identical wrapping; the suffix only signalled "in-place refreshable" but the .snap ID + terminal-shortcode body in DOCS_SNAPSHOT_MARKER_PATTERN already discriminate that. Standardised on a single open prefix and stripped the -HTML literals from README.md, the four standalone docs files, and the test file.
  • Help-page marker uses the shared prefix. The mirrored close (<!-- END AUTO-GENERATED from \wt --help-page` -->) stays as-is because adjacent regions need unambiguous pairing, but the open prefix now goes through MARKER_OPEN_PREFIX`.
  • Drop MarkerType::output_format() / extract_inner(). Both had a single trivial non-panic branch that existed only to enforce "no Snapshot markers in README" via unreachable!(). Replaced with one explicit assertion in sync_readme_markers — surfaces the invariant as an actionable error message instead of a panic.
  • Collapse format_replacement. wrap_in_marker is invoked once for both output formats; only body construction varies.
  • __WT_QUOT__ rename in tests/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 in src/docs.rs.

Net diff: -7 lines.

Test plan

  • cargo test --test integration — full integration suite (1559 tests) pass
  • cargo test --test integration readme_sync — all 13 sync tests pass; test_readme_examples_are_in_sync now 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 Tera
  • 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 (AUTO-GENERATED-HTML, __WT_OPEN2__, trailing |||)
  • cargo clippy --all-targets --all-features — clean
  • cargo fmt --check — clean

🤖 Generated with Claude Code

…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]>
@max-sixty
max-sixty merged commit 8abefbc into main Apr 25, 2026
25 checks passed
@max-sixty
max-sixty deleted the docs/static-output-for-gif-pages branch April 25, 2026 23:57
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants