pub struct Document { /* private fields */ }document only.Expand description
An ordered list of blocks that make up a command’s human output.
Every builder method takes self and returns it, so a document reads as
one chain. A command’s Present implementation returns one, and a
Section nests one as its body.
Implementations§
Source§impl Document
impl Document
Sourcepub fn heading(self, value: impl Into<Text>) -> Self
pub fn heading(self, value: impl Into<Text>) -> Self
Append a heading. It is styled with Role::Heading and wraps to the
width.
Sourcepub fn paragraph(self, value: impl Into<Text>) -> Self
pub fn paragraph(self, value: impl Into<Text>) -> Self
Append prose that wraps to the width. Spans keep their roles.
Sourcepub fn verbatim(self, value: impl Into<String>) -> Self
pub fn verbatim(self, value: impl Into<String>) -> Self
Append preformatted text that is never wrapped or styled.
See Block::Verbatim for the characters the renderer removes.
Sourcepub fn table(self, table: Table) -> Self
pub fn table(self, table: Table) -> Self
Append a table. Its frame follows the table frame of the render options.
Sourcepub fn section(self, section: Section) -> Self
pub fn section(self, section: Section) -> Self
Append a section: a heading directly over a nested document.
Sourcepub fn notice(self, notice: Notice) -> Self
pub fn notice(self, notice: Notice) -> Self
Append a notice: a level label, an optional code, and a message.
Sourcepub fn rule(self, title: Option<Text>) -> Self
pub fn rule(self, title: Option<Text>) -> Self
Append a horizontal rule across the width. A title is drawn in the
rule with Role::Heading.
Source§impl Document
impl Document
Sourcepub fn render(&self, options: RenderOptions) -> String
Available on crate feature render only.
pub fn render(&self, options: RenderOptions) -> String
render only.Render with explicit semantic options; see RenderOptions.
The string is a pure function of the document and the options: no terminal is asked. The document lays out to the explicit width, else the fallback width, else its natural width.
Styles are written only under ColorMode::Always, as the theme gives
them, at full colour depth. ColorMode::Auto has no stream to look
at here and writes none. A View and help write to a stream, so they
decide width and colour for it instead.