Skip to content

Improve public rustdocs - #23

Merged
the-mikedavis merged 3 commits into
helix-editor:masterfrom
joshka:joshka/improve-rustdocs
May 30, 2026
Merged

the-mikedavis merged 3 commits into
helix-editor:masterfrom
joshka:joshka/improve-rustdocs

Conversation

@joshka

@joshka joshka commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Improve Termina's public rustdocs so the crate is easier to evaluate and use as a terminal backend.

This is a docs-only change. It expands module, type, variant, and method documentation across the public API so docs.rs readers can understand the terminal, parser, event, escape-sequence, and style surfaces without reading the implementation first.

Motivation

Ratatui has an open request to consider Termina as a backend:

ratatui/ratatui#1784

Before that is practical, Termina needs a stronger user-facing documentation surface. This pass documents the current API rather than changing behavior.

I maintain Ratatui and crossterm, so I tried to bring that support and review experience into this pass. In particular, the docs now call out recurring sources of user confusion around terminal input: key press/release events, terminal-dependent key encoding, modifier handling, mouse coordinates, raw/cooked mode behavior, and platform differences.

What changed

  • Added module-level overviews and examples for the crate, events, parser, terminal handles, escape sequences, and styling.
  • Expanded docs for public enums, structs, variants, fields, and methods.
  • Added examples for event reading, parser usage, CSI/OSC/DCS construction, SGR styling, colors, and terminal operations.
  • Linked protocol concepts to local rustdoc types where possible and to public specs/docs where useful.
  • Clarified terminal-specific behavior such as key press/release events, character normalization, mouse coordinates, raw/cooked mode differences, and Windows legacy input.
  • Preserved implementation context for upstream influences such as crossterm, termwiz, xterm, Kitty keyboard protocol, and DEC/xterm terminal specs.

Review Notes

This is intentionally a broad documentation pass. I manually reviewed and steered the public docs for correctness and tone, with extra attention to the event, parser, terminal, and style APIs.

The main remaining review caveat is the CSI/DCS/OSC reference docs. Those sections are repetitive protocol enum documentation, and I have not manually reviewed every variant with the same depth as the rest of the crate. The examples, links, and rustdoc formatting for those sections were validated mechanically.

No runtime behavior is intended to change.

Validation

Ran:

cargo fmt
RUSTDOCFLAGS='-D missing_docs -D rustdoc::broken_intra_doc_links' cargo doc --no-deps --all-features
RUSTDOCFLAGS='-D rustdoc::broken_intra_doc_links' cargo doc --no-deps --all-features --document-private-items
cargo clippy --all-targets --all-features
cargo test --all-features

Expand Termina's public documentation so docs.rs readers can
understand the terminal, parser, event, escape-sequence, and style
APIs without first reading the implementation. This is a docs-only
change aimed at making the crate easier to evaluate as a possible
Ratatui backend.

Document recurring terminal-input pitfalls from Ratatui and crossterm
maintenance experience, including key press/release behavior,
terminal-dependent key encoding, modifier state, mouse coordinates,
raw/cooked mode behavior, and platform differences. Add examples and
links for the main construction and parsing paths while preserving
implementation context for upstream influences and terminal specs.

@the-mikedavis the-mikedavis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, thanks @joshka! I want to merge this basically as-is. I have one nit though: I'd also update the README to note that "CREDIT" comments have moved into implementation notes sections (https://github.com/helix-editor/termina#credit)

@the-mikedavis

Copy link
Copy Markdown
Member

Looks like the docs CI found a nit on Windows as well

Update README guidance for implementation note credits and fix the
Windows CI failure blocking the documentation PR.
@joshka
joshka force-pushed the joshka/improve-rustdocs branch from 56f2e8f to b559655 Compare May 28, 2026 01:25
Comment thread README.md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got reformatted by markdown lint. I usually use 100 char lines and align tables. Hope that's ok here. It generally edits easier that way. (Easier diffs in github etc.). Happy to revert that part as I know it's fairly subjective choice.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah I'd prefer to keep the style of the README mostly unchanged. I like to avoid hard wrapping in markdown. Making the table slimmer seems alright though, it's very wide right now. Maybe we can say "terminal dependent" and have a footnote or cross/star symbol that says that it depends on Kitty keyboard support below the table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 05b5fe7

Comment thread README.md Outdated
@joshka

joshka commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Both comments addressed.

Keep the README closer to its existing unwrapped prose style while
retaining the slimmer Windows input comparison table requested during
review.
@the-mikedavis
the-mikedavis merged commit 88c34d1 into helix-editor:master May 30, 2026
9 checks passed
@the-mikedavis

Copy link
Copy Markdown
Member

Thanks again!

@joshka
joshka deleted the joshka/improve-rustdocs branch August 7, 2026 03:37
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