Repository navigation
docs(pages): add static command output to sections dominated by GIFs - #2405
Conversation
Five docs pages previously relied on GIFs for the only visible output (merge, step, remove, hook, llm-commits). Add plain-text example output in-line under each Examples section so readers can see the flow without waiting for the GIF to cycle. Content mirrors the docs/demos/snapshots captures and uses the actual wt output format verified against integration snapshots. Addresses #2403. Co-Authored-By: Claude Opus 4.7 <[email protected]>
Address review feedback on PR #2405: - hook.md: remove the "each hook execution prints..." sentence and let the examples speak for themselves; add a second example for background (post-start) hooks - remove.md: rename @ repo to @ acme so the example reads as a real project name rather than a placeholder Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Why is the content hand-written? Can we instead generate it from a snapshot like we do the existing examples? |
|
It can — I went hand-written so the same examples flow into The trade-off: snapshot fixtures show generic content ( |
Replace the hand-written ```console``` blocks on merge.md, step.md,
remove.md, and hook.md (plus the hand-crafted HTML on llm-commits.md)
with snapshot-driven content. One source — a scripted integration test
that runs the real command against mocked binaries — feeds three
surfaces: terminal `wt <cmd> --help`, the docs site's colorized terminal
shortcode, and the skill reference's plain block.
Six new tests produce the realistic snapshots (cargo nextest, flyctl
scale, LLM-generated commit messages). The sync pipeline gains a
write-back pass that fills the ```console``` bodies in src/cli/mod.rs
from the registered snapshot before --help-page reads the file, so the
terminal output stays faithful without manual maintenance.
As a side effect, fixes a pre-existing bug in docs/content/list.md: the
HTML-mode expansion of `<!-- wt list -->` placeholders was silently
broken because COMMAND_PLACEHOLDER_PATTERN expected ```bash fences but
convert_dollar_console_to_terminal had already rewritten them to
`{{ terminal() }}` shortcodes. The extended pattern matches all three
forms (bash, self-closing terminal, terminal-with-body) and strips the
trailing `|||` corruption that blank lines in snapshot bodies would
introduce.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
# Conflicts: # tests/integration_tests/readme_sync.rs
The skills/worktrunk/reference/*.md linguist-generated=true pattern over-matches the three primary-source files (README, shell-integration, troubleshooting) — their edits get collapsed in GitHub PR diffs. Flag the exemption requirement inline with the skill-only files entry so the next person adding one knows the rule. Co-Authored-By: Claude <[email protected]>
Three small consolidations across the help.rs producer and the readme_sync.rs consumer: - BADGE_EXPERIMENTAL_HTML moves from src/help.rs to worktrunk::docs. The skill-file generator strips the same literal back to `[experimental]`; sharing the const turns a divergence into a compile-time break instead of HTML leaking silently into skill files. - SUBDOC_MARKER_PREFIX and DEMO_MARKER_PREFIX replace four local `const PREFIX: &str = "<!-- subdoc: ";` (and `demo:`) declarations. The marker convention is now documented in one place rather than re-declared at each call site. - normalize_clap_help_fences() de-duplicates the `text→` plus `console→bash` replacement pair shared by --help-md and help_reference_inner. The PageMode::transform_raw site is intentionally not collapsed: its input is `after_long_help` markdown which never contains clap's `text` blocks. No behavior change. Co-Authored-By: Claude <[email protected]>
Reviewer flagged that "Switched to worktree for main @ repo" reads as a project name, not a worktree path. Other placeholders already use a prefix (`../repo`, `../repo.branch`); _REPO_ was the lone exception rendering as bare "repo". Use `~/repo` (and `~/repo.branch`) to match the path-like form, applied uniformly across all snapshots that reach docs and skill files. Co-Authored-By: Claude <[email protected]>
…RATED marker constants (#2417) ## 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 - [x] `cargo test --lib docs::tests::test_convert_dollar_console_to_terminal` — exercises new mixed-block case + existing command-only / multi-cmd / comment cases - [x] `cargo test --test integration readme_sync` — 13 sync tests still pass after the refactor and bandage removal - [x] `cargo test --test integration` — full integration suite (1558 tests) pass - [x] 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. - [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]>
Summary
Adds static command-output blocks to the docs pages dominated by GIFs (addresses #2403). The blocks are driven from insta snapshots so they stay in lockstep with what
wtactually prints — one source flows to all three surfaces:wt <cmd> --help(plain text, gutter-formatted)docs/content/*.md(colorized{% terminal(cmd="...") %}shortcode)skills/worktrunk/reference/*.md(plain$ cmd\noutput\nblock)What changed
Six scripted snapshot tests produce realistic output (
cargo nextest run,flyctl scale count 0, LLM-generated commit messages):test_docs_merge_pre_merge_hook—wt mergewith pre-merge hooktest_docs_step_commit_llm—wt step commitwith LLMtest_docs_step_squash_llm— three-commit squash with LLMtest_docs_merge_squash_llm—wt merge(squash + LLM + merge) forllm-commits.mdtest_docs_remove_pre_remove_hook—wt removewith pre-remove hooktest_docs_hook_pre_merge—wt hook pre-mergedirect invocationSync pipeline extension in
tests/integration_tests/readme_sync.rs:sync_cli_mod_example_bodiesfills theconsolebody in each<!-- wt <cmd> (docs-example) -->placeholder insrc/cli/mod.rsfrom the registered snapshot. Runs before--help-pagereads the file.COMMAND_PLACEHOLDER_PATTERNextended to match three forms (bash,{{ terminal() }}self-closing,{% terminal %} body {% end %}). This fixes a pre-existing bug indocs/content/list.mdwhere the HTML-mode expansion was silently broken.|||corruption that arises when blank lines in snapshot bodies are interpreted as empty commands byconvert_dollar_console_to_terminal.Docs page migration:
src/cli/mod.rs— replaced four hand-writtenconsoleblocks (merge, step, remove, hook) with<!-- wt <cmd> (docs-example) -->markers.docs/content/llm-commits.md— replaced three hand-crafted HTML blocks with<!-- ⚠️ AUTO-GENERATED-HTML from X.snap -->markers.Refactor follow-up in a separate commit:
BADGE_EXPERIMENTAL_HTML,SUBDOC_MARKER_PREFIX,DEMO_MARKER_PREFIXhoisted toworktrunk::docsso producer and consumer stay in lockstep.normalize_clap_help_fences()consolidates thetext→+console→bashreplacement pair shared by--help-mdandhelp_reference_inner.CLAUDE.md note documenting the
.gitattributeslinguist-generated=falseexemption requirement when adding skill-only files (carryover from chore(tests): factor write_tracked helper; mark generated files #2409).Test plan
cargo test --test integration readme_sync— all 13 tests pass, idempotentcargo test --test integration test_help— help snapshots updatedcargo run -- {merge,remove,step,hook} --help— clean gutter formatting, no visible HTML commentscargo run -- hook pre-merge --yes— full project gate green (3355 tests)🤖 Generated with Claude Code