Documentation
¶
Overview ¶
Package asciitable renders caller-owned rows as ASCII tables.
It is intentionally independent of Spanner plan protobufs and plantree types: callers build rows from their own plan model, then provide column definitions and predicate accessors for the cells they want to show.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderAppendix ¶
func RenderAppendix[T any](rows []T, spec AppendixSpec[T]) (string, error)
RenderAppendix formats an appendix for rows with associated items.
func RenderTable ¶
RenderTable renders rows using spec.
func RenderTableless ¶ added in v0.3.0
RenderTableless renders rows without headers or a table grid, using "|" as a one-character column separator. The separator is not escaped, so the output is intended for human display rather than machine parsing. Trailing empty cells are omitted from each physical line, while empty physical lines and entirely empty logical rows are preserved as blank output lines.
Right-aligned columns are left-padded to their own maximum content width; left-aligned columns are not padded, so wide text columns do not reintroduce table-grid width. Center alignment is not supported by this layout and is rendered as unpadded text.
Types ¶
type Alignment ¶
type Alignment string
Alignment controls horizontal alignment for a rendered column. The zero value means AlignLeft.
type AppendixSpec ¶
type AppendixSpec[T any] struct { // Title is printed before item lines. It must be non-empty. Title string // ID returns the non-negative display ID used in the appendix. ID func(row T) uint // Items returns the item lines associated with the row. Items func(row T) []string }
AppendixSpec defines how appendices read row IDs and item lines.
type Column ¶
type Column[T any] struct { // Header is the column header text. Header string // Alignment controls the cell alignment. The zero value uses [AlignLeft]. Alignment Alignment // Cell returns the rendered cell text for each row. Cell CellFunc[T] }
Column defines one rendered table column.