Skip to content

docs(pages): add static command output to sections dominated by GIFs - #2405

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

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

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Collaborator

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 wt actually prints — one source flows to all three surfaces:

  • terminal wt <cmd> --help (plain text, gutter-formatted)
  • docs/content/*.md (colorized {% terminal(cmd="...") %} shortcode)
  • skills/worktrunk/reference/*.md (plain $ cmd\noutput\n block)

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 merge with pre-merge hook
    • test_docs_step_commit_llm — wt step commit with LLM
    • test_docs_step_squash_llm — three-commit squash with LLM
    • test_docs_merge_squash_llm — wt merge (squash + LLM + merge) for llm-commits.md
    • test_docs_remove_pre_remove_hook — wt remove with pre-remove hook
    • test_docs_hook_pre_merge — wt hook pre-merge direct invocation
  • Sync pipeline extension in tests/integration_tests/readme_sync.rs:

    • New write-back pass sync_cli_mod_example_bodies fills the console body in each <!-- wt <cmd> (docs-example) --> placeholder in src/cli/mod.rs from the registered snapshot. Runs before --help-page reads the file.
    • COMMAND_PLACEHOLDER_PATTERN extended to match three forms (bash, {{ terminal() }} self-closing, {% terminal %} body {% end %}). This fixes a pre-existing bug in docs/content/list.md where the HTML-mode expansion was silently broken.
    • Stripped trailing ||| corruption that arises when blank lines in snapshot bodies are interpreted as empty commands by convert_dollar_console_to_terminal.
  • Docs page migration:

    • src/cli/mod.rs — replaced four hand-written console blocks (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_PREFIX hoisted to worktrunk::docs so producer and consumer stay in lockstep.
    • normalize_clap_help_fences() consolidates the text→ + console→bash replacement pair shared by --help-md and help_reference_inner.
  • CLAUDE.md note documenting the .gitattributes linguist-generated=false exemption 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, idempotent
  • cargo test --test integration test_help — help snapshots updated
  • cargo run -- {merge,remove,step,hook} --help — clean gutter formatting, no visible HTML comments
  • cargo run -- hook pre-merge --yes — full project gate green (3355 tests)
  • Visual check on dev site (maintainer — terminal shortcodes now render with colors via ANSI→HTML; dark/light variants both expected to look like the GIFs they replace)

🤖 Generated with Claude Code

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]>
Comment thread docs/content/hook.md Resolved
Comment thread docs/content/remove.md Resolved
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]>
@max-sixty

Copy link
Copy Markdown
Owner

Why is the content hand-written? Can we instead generate it from a snapshot like we do the existing examples?

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

It can — I went hand-written so the same examples flow into wt <cmd> --help. The existing snapshot examples (worktrunk.md, claude-code.md, tips-patterns.md) live in markdown only, not in --help. Real snapshots that fit these slots already exist: merge_pre_commit_command_success, step_commit_with_no_hooks_flag, pre_remove_hook_executes, merge_auto_commit_with_llm.

The trade-off: snapshot fixtures show generic content (echo 'Pre-commit check passed', feature.txt, feat: add file) rather than the recognizable cargo nextest/flyctl scale commands I hand-wrote. If you'd rather have realistic commands, hand-written stays; if faithful-to-actual-output matters more, I'll rework using <!-- AUTO-GENERATED-HTML from ...snap --> markers and drop the examples from after_long_help. Which way?

max-sixty and others added 5 commits April 24, 2026 13:22
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]>
@max-sixty
max-sixty merged commit 5f126d2 into main Apr 24, 2026
23 checks passed
@max-sixty
max-sixty deleted the docs/static-output-for-gif-pages branch April 24, 2026 23:40
max-sixty added a commit that referenced this pull request Apr 25, 2026
…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]>
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