Skip to main content

Crate termdoc_core

Crate termdoc_core 

Source
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. OK is 0 even when warnings were emitted: a document rendered with one questionable table is still a success.

Structs§

BackendCaps
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. width is the display-cell width already computed by the layout; the backend does not measure again.
Metadata
ReadContext
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.
ReaderCaps
What a reader can do. The CLI consults this to know, for instance, whether offering --page makes 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§

AdmonitionKind
Align
BreakKind
Color
Error
Event
FormatId
ImageSource
A handle to an image; never pixels.
Marker
A list item’s bullet. The layout picks the glyph based on Fidelity.
NamedColor
Origin
Severity
Tag
TagKind
Tag’s discriminant, so End does 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.
DocumentReader
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 Diagnostic and docs/DESIGN.md §7).
Result