Expand description
termdoc’s shared vocabulary: the document model, the pipeline traits, and input sources.
This crate depends on no other termdoc crate. Readers depend only on it; backends
cannot see readers either. That separation is not a convention but Cargo’s dependency
graph, verified by crates/termdoc-cli/tests/layering.rs.
The full architecture lives in docs/DESIGN.md.
Modules§
- confidence
- exit
- Process exit codes.
OKis 0 even when warnings were emitted: a document rendered with one questionable table is still a success.
Structs§
- Backend
Caps - Detection
- Diagnostic
- A recoverable problem found while reading. It travels inside the stream so that rendering can continue; where it ends up —dimmed inline on a TTY, on stderr in a pipe— is the CLI’s decision, not the reader’s.
- Line
- One line of output.
widthis the display-cell width already computed by the layout; the backend does not measure again. - Metadata
- Read
Context - Options a reader needs to know about. Deliberately excludes width and color: those belong to the layout and the backend, and leaking them here would re-couple the stages.
- Reader
Caps - What a reader can do. The CLI consults this to know, for instance, whether offering
--pagemakes any sense. - Registry
- Segment
- A contiguous run of text sharing a single style.
- Source
- Span
- Where an event came from in the source.
- Spanned
- An event together with its location.
- Style
Enums§
- Admonition
Kind - Align
- Break
Kind - Color
- Error
- Event
- Format
Id - Image
Source - A handle to an image; never pixels.
- Marker
- A list item’s bullet. The layout picks the glyph based on
Fidelity. - Named
Color - Origin
- Severity
- Tag
- TagKind
Tag’s discriminant, soEnddoes not have to carry the payload again.
Constants§
- PROBE_
SIZE - How many prefix bytes are available for detection without consuming the input. 8 KiB comfortably covers any structural sniff (docs/DESIGN.md §4).
Traits§
- Backend
- Writes laid-out lines. Sees neither events nor readers.
- Detector
- Proposes a format based on the source’s prefix.
- Document
Reader - Turns bytes into the internal model. This is what the original design called a “Renderer”: it produces the document, it does not paint it.
- Transform
- Transforms the stream. These chain for free because they are iterator adapters.
Type Aliases§
- Confidence
- The 0..=100 confidence with which a detector claims a format.
- Events
- The stream. Fallible per event: a document that turns out to be corrupt halfway
through must not invalidate what was already emitted (see
Diagnosticand docs/DESIGN.md §7). - Result