Skip to content

refactor(docs): fix blank-line cmd-stream corruption; share AUTO-GENERATED marker constants - #2417

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

max-sixty merged 2 commits into
mainfrom
docs/static-output-for-gif-pages

Conversation

@max-sixty

@max-sixty max-sixty commented Apr 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Three small follow-ups + a placeholder rename, all from #2405 review feedback.

  • Root-cause fix for ||| corruption. convert_dollar_console_to_terminal was promoting blank lines inside mixed \$ cmd + output blocks to extra cmd= entries, dropping the blank from the rendered body and emitting a stray \$ prompt (e.g. cmd=\"wt list|||\"). Now distinguishes command-only blocks (blanks are visual spacing in cmd=) from mixed blocks (blanks belong to body). Removes the matching trim_end_matches('|') bandage in expand_command_placeholders. New unit test in src/docs.rs covers the mixed-block case.
  • Single-pass classification. Folded the two filter chains over block_lines into one loop with one match — fewer branches, no duplicated predicates.
  • AUTO-GENERATED marker consolidation. Within tests/integration_tests/readme_sync.rs, the <!-- ⚠️ AUTO-GENERATED ... --> literal appeared in four producer / regex sites with subtly different shapes (HTML vs plain, ID format). Factored into MARKER_OPEN_PREFIX / MARKER_OPEN_HTML_PREFIX / MARKER_CLOSE constants plus a wrap_in_marker() helper, and threaded those constants into the regexes via regex::escape. Pure refactor — no docs/skill files regenerated.
  • __WT_OPEN2__ / __WT_CLOSE2__ → __WT_OPEN__ / __WT_CLOSE__. The 2 was meant to distinguish doubled-brace placeholders from hypothetical single-brace ones, but Tera only treats {{/}} (not single braces) as template delimiters — there's no second variant to disambiguate from. Updated the producer (src/docs.rs), the test-side decoder (tests/integration_tests/readme_sync.rs), the Zola template (docs/templates/shortcodes/terminal.html), the docs-site CLAUDE.md, and the regenerated docs/content/{step,hook}.md.

Test plan

  • cargo test --lib docs::tests::test_convert_dollar_console_to_terminal — exercises new mixed-block case + existing command-only / multi-cmd / comment cases
  • cargo test --test integration readme_sync — 13 sync tests still pass after the refactor and bandage removal
  • cargo test --test integration — full integration suite (1558 tests) pass
  • Visual check via local Zola dev server: /merge/, /step/, /remove/, /hook/, /llm-commits/, and /list/ all render terminal blocks cleanly with no ||| artifacts and no leaked placeholder strings (__WT_OPEN__ etc. don't appear in served HTML). The multi-command jq recipes block on /list/ continues to render comments as bash-styled section headers.
  • cargo clippy --all-targets --all-features — clean
  • cargo fmt --check — clean

🤖 Generated with Claude Code

max-sixty and others added 2 commits April 25, 2026 16:06
…; consolidate AUTO-GENERATED markers

`convert_dollar_console_to_terminal` was promoting blank lines inside
mixed `$ cmd + output` blocks to extra cmd= entries (`wt list|||`),
which both dropped the blank from the rendered body and emitted a stray
`$ ` prompt. Distinguish command-only blocks (where blanks are visual
spacing) from mixed blocks (where blanks belong to the body), and fold
the two filter passes into a single classification loop. Removes the
matching `trim_end_matches('|')` bandage in `expand_command_placeholders`.

Within `tests/integration_tests/readme_sync.rs`, factor the four copies
of the `<!-- ⚠️ AUTO-GENERATED ... -->` literal into shared
`MARKER_OPEN_PREFIX` / `MARKER_OPEN_HTML_PREFIX` / `MARKER_CLOSE`
constants plus a `wrap_in_marker()` helper, and feed those constants
into the consuming regexes.

Co-Authored-By: Claude <[email protected]>
…CLOSE__

The `2` suffix was meant to distinguish "double brace" placeholders from
hypothetical single-brace ones, but Tera only treats `{{`/`}}` (not single
braces) as template delimiters, so there's no second variant to disambiguate
from. Drop the noise.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 1e053d2 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:21
max-sixty added a commit that referenced this pull request Apr 25, 2026
…oss crate boundary (#2418)

## 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 <cmd> --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

- [x] `cargo test --test integration` — full integration suite (1559
tests) pass
- [x] `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)
- [x] `cargo test --test integration
test_args_indexing_and_length_in_hook_template` — confirms the
user_hooks single-quote inlining works through TOML and Tera
- [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 (`AUTO-GENERATED-HTML`,
`__WT_OPEN2__`, trailing `|||`)
- [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