spruce/group

Depth-in-context grouped output helpers.

Values

pub fn group(
  sp: spruce.Spruce,
  title: String,
  body: fn(spruce.Spruce) -> result,
) -> result

Print a group title, then run body with a context indented one level deeper.

This is the eager, streaming form of grouping: the title prints immediately and body runs right away, so its output appears as work happens and it may perform IO and return any value. For deferred, pipe-composable grouping that buffers output instead, see spruce/output.group.

pub fn indent(text: String, level: Int) -> String

Prefix every line in text with two spaces for each indent level.

pub fn render_title(sp: spruce.Spruce, title: String) -> String

Render a group title line (indent prefix + styled marker + title), the same line that group prints. Exposed so buffered output (spruce/output) can compose group titles without duplicating the styling.

Search Document