Skip to content

refactor(help): unify --help-page plain/web paths; link-check .txt - #2412

Merged
max-sixty merged 2 commits into
mainfrom
llm-docs
Apr 24, 2026
Merged

max-sixty merged 2 commits into
mainfrom
llm-docs

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Two independent follow-ups from #2404 (llms.txt PR), surfaced during that session:

1. refactor(help): unify --help-page plain/web paths behind PageMode
Replaces plain: bool threaded through four functions (handle_help_page, format_subcommand_section, expand_subdoc_placeholders, and the caller in maybe_handle_help_with_pager) with a PageMode { Web, Plain } enum. The enum's methods encapsulate each mode-dependent branch — color choice, raw-help transforms, body/subdoc-trailing processing, the experimental badge, and the page header/footer. Result: ~10 if plain { ... } else { ... } branches become single method calls; the bool→enum switch also catches Self::_ exhaustiveness if new modes are added. Extracts BADGE_EXPERIMENTAL_HTML as a constant to dedupe the empty-span literal between experimental_marker and post_process_for_html.

2. chore(ci): link-check .txt files with lychee
Switches the lychee-system pre-commit hook from types: [markdown] to files: '\.(md|txt)$' so docs/static/llms.txt URLs get verified alongside .md docs. identify has no .txt tag, so a files-regex is the clearest way to widen the set.

Test plan

  • test_command_pages_and_skill_files_are_in_sync — passes unchanged (byte-identical --help-page output for both modes)
  • test_help — all 40 snapshot tests pass
  • cargo test --lib --bins — 606 unit tests pass
  • cargo clippy --all-targets --all-features -- -D warnings — clean
  • pre-commit run --all-files — all hooks pass, including lychee-system on the expanded file set (llms.txt URLs already check out)

🤖 Generated with Claude Code

max-sixty and others added 2 commits April 24, 2026 11:58
Replace `plain: bool` threaded through four functions with a
`PageMode { Web, Plain }` enum whose methods encapsulate every
mode-dependent branch: color choice, raw-help transforms, body
processing, subdoc trailing, experimental badge, header, footer.

Collapses ~10 `if plain { ... } else { ... }` branches into single
method calls. Also extracts `BADGE_EXPERIMENTAL_HTML` constant so
the empty-span literal isn't duplicated between `experimental_marker`
and `post_process_for_html`.

Output is byte-identical —
test_command_pages_and_skill_files_are_in_sync passes unchanged, as
do the 40 help snapshot tests.

Co-Authored-By: Claude <[email protected]>
Switch the lychee-system hook's file filter from `types: [markdown]`
to `files: '\.(md|txt)$'` so docs/static/llms.txt URLs get verified
alongside the .md docs. identify has no `.txt` tag, so a files-regex
is the clearest way to widen the set.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit cadf392 into main Apr 24, 2026
25 checks passed
@max-sixty
max-sixty deleted the llm-docs branch April 24, 2026 19:11
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