spruce/item

Pure bullet and ordered list rendering.

An Items value is a list of labelled entries rendered with an explicit Spruce context. Bullet lists use a Unicode bullet (•) when the context symbol mode is Unicode and a plain ASCII marker (-) when it is Ascii. Ordered lists count from one at each nesting depth.

item.new()
|> item.kind(item.Ordered)
|> item.item("setup")
|> item.nested("build", item.new() |> item.item("erlang"))
|> item.render(context, _)

Types

A list of labelled items.

pub opaque type Items

The marker style used by the default enumerator.

pub type Kind {
  Bullet
  Ordered
}

Constructors

  • Bullet
  • Ordered

Values

pub fn child(
  items: Items,
  label: String,
  children: List(String),
) -> Items

Add a top-level item with one level of child labels.

pub fn enumerator(
  items: Items,
  enumerate: fn(Int, Int) -> String,
) -> Items

Set a custom enumerator.

The function receives the one-based item index within the current depth and the one-based depth of the item being rendered. It should return the complete marker to place before that item’s first label line.

pub fn item(items: Items, label: String) -> Items

Add a top-level item, preserving insertion order.

pub fn kind(items: Items, kind: Kind) -> Items

Set the default marker style for the list.

pub fn nested(
  items: Items,
  label: String,
  children: Items,
) -> Items

Add a top-level item whose children come from another list.

The nested list’s item tree is preserved, while the parent list’s kind and enumerator control rendering at every depth.

pub fn new() -> Items

Build an empty bullet list.

pub fn render(context: spruce.Spruce, items: Items) -> String

Render a list to a string.

✨ Search Document