Liking cljdoc? Tell your friends :D

clj-string-layout.table

High-level table API built on top of the layout DSL.

Use this namespace when you want named output formats, headers, map rows, and column specs without writing layout strings directly. Drop down to clj-string-layout.core/layout when you need full DSL control.

High-level table API built on top of the layout DSL.

Use this namespace when you want named output formats, headers, map rows, and
column specs without writing layout strings directly. Drop down to
clj-string-layout.core/layout when you need full DSL control.
raw docstring

columns-fromclj

(columns-from sample)
(columns-from sample overrides)

Derive a :columns vector from a sample row.

The sample can be either a single row map or a sequence whose first item is a row map. Each key in the sample becomes a column source — the column's :from is the key and its :as defaults to (name key). Insertion order is preserved (use an array-map or sorted-map if your sample has more than 8 keys and you need a specific order).

Default alignment is :right for numeric values (Long, Double, etc.) and :left for everything else. Pass overrides as a map keyed by source key to customise individual columns; supported override keys are :as, :align, :formatter, :width, and :overflow.

(columns-from {:item "apple" :qty 12 :price 1.50})
;; => [{:from :item :as "item"}
;;     {:from :qty :as "qty" :align :right}
;;     {:from :price :as "price" :align :right}]

(columns-from rows
              {:price {:as "Price"
                       :formatter #(format "$%.2f" %)}})
Derive a :columns vector from a sample row.

The sample can be either a single row map or a sequence whose first item is
a row map. Each key in the sample becomes a column source — the column's
:from is the key and its :as defaults to (name key). Insertion order is
preserved (use an array-map or sorted-map if your sample has more than 8
keys and you need a specific order).

Default alignment is :right for numeric values (Long, Double, etc.) and
:left for everything else. Pass overrides as a map keyed by source key to
customise individual columns; supported override keys are :as, :align,
:formatter, :width, and :overflow.

    (columns-from {:item "apple" :qty 12 :price 1.50})
    ;; => [{:from :item :as "item"}
    ;;     {:from :qty :as "qty" :align :right}
    ;;     {:from :price :as "price" :align :right}]

    (columns-from rows
                  {:price {:as "Price"
                           :formatter #(format "$%.2f" %)}})
sourceraw docstring

format-infoclj

(format-info format)

Returns registry information for a named table format.

The returned map is descriptive and may contain implementation details such as :layout. It is useful for discovery, but callers should prefer table APIs over relying on this map's exact shape.

Returns registry information for a named table format.

The returned map is descriptive and may contain implementation details such as
:layout. It is useful for discovery, but callers should prefer table APIs over
relying on this map's exact shape.
sourceraw docstring

formatsclj

(formats)

Returns the set of named formats accepted by table, table-str, and table-seq.

Returns the set of named formats accepted by table, table-str, and table-seq.
sourceraw docstring

(print-table spec)

Renders a high-level table spec and prints it to out, one line per row.

Convenience wrapper for the common REPL pattern of (println (table-str ...)). Returns nil.

Renders a high-level table spec and prints it to *out*, one line per row.

Convenience wrapper for the common REPL pattern of (println (table-str ...)).
Returns nil.
sourceraw docstring

tableclj

(table spec)

Renders a high-level table spec to a vector of output lines.

The spec map accepts:

:rows - data rows. Vectors of values, or maps when :columns name keys. :headers - shorthand: a vector of header labels for vector rows. :columns - column definitions (see below). Required for map rows that need labels, alignment, formatting, width, or overflow. :footers - rows that render below the data, sharing column treatment. :title - centered caption above text formats; <caption> for :html. :format - named output format (:plain, :markdown, :box, ...). :width - target total width for fill-aware formats. :fill? - true to expand the generated format toward :width. :raw? - return vectors of pieces instead of joined strings. :escape? - false to skip the per-format cell escaper. :cell-fn - per-cell decoration callback (see below).

Column definitions (entries in :columns) come in two shapes:

:qty ; bare keyword: from :qty, as "qty" {:from :qty ; map: required for anything beyond defaults :as "Qty" :align :right :formatter f :width 8 :overflow :ellipsis}

Map column keys: :from (source key for map rows; omit for vector rows to use the column's position), :as (header label; defaults to the source keyword name), :align (:left, :center, :right, :verbatim), :formatter (1-arg fn applied to the value), :width (max display width), :overflow (:none, :clip, :ellipsis, :wrap, :error).

:cell-fn receives {:section (:header, :data, or :footer), :row (index within the section), :col (column index), :column (the normalised column spec), :value (the post-formatter, post-escape value)} and must return a string. Pair it with :display-width width/ansi-width when adding ANSI styling so the engine still pads using the visible width.

:width and :display-width are ignored for :html output (HTML is structural markup, not padded text); :raw? is honored everywhere.

Renders a high-level table spec to a vector of output lines.

The spec map accepts:

  :rows      - data rows. Vectors of values, or maps when :columns name keys.
  :headers   - shorthand: a vector of header labels for vector rows.
  :columns   - column definitions (see below). Required for map rows that
               need labels, alignment, formatting, width, or overflow.
  :footers   - rows that render below the data, sharing column treatment.
  :title     - centered caption above text formats; <caption> for :html.
  :format    - named output format (:plain, :markdown, :box, ...).
  :width     - target total width for fill-aware formats.
  :fill?     - true to expand the generated format toward :width.
  :raw?      - return vectors of pieces instead of joined strings.
  :escape?   - false to skip the per-format cell escaper.
  :cell-fn   - per-cell decoration callback (see below).

Column definitions (entries in :columns) come in two shapes:

  :qty                        ; bare keyword: from :qty, as "qty"
  {:from :qty                 ; map: required for anything beyond defaults
   :as "Qty"
   :align :right
   :formatter f
   :width 8
   :overflow :ellipsis}

Map column keys: :from (source key for map rows; omit for vector rows
to use the column's position), :as (header label; defaults to the
source keyword name), :align (:left, :center, :right, :verbatim),
:formatter (1-arg fn applied to the value), :width (max display
width), :overflow (:none, :clip, :ellipsis, :wrap, :error).

:cell-fn receives {:section (:header, :data, or :footer), :row (index
within the section), :col (column index), :column (the normalised
column spec), :value (the post-formatter, post-escape value)} and must
return a string. Pair it with :display-width width/ansi-width when
adding ANSI styling so the engine still pads using the visible width.

:width and :display-width are ignored for :html output (HTML is
structural markup, not padded text); :raw? is honored everywhere.
sourceraw docstring

table-into!clj

(table-into! writer spec)

Writes a rendered table to a java.io.Writer, one line per write.

Each line is followed by a single newline. Returns the writer. The table is rendered eagerly via table; pair with clj-string-layout.core/layout-into! for streaming behavior on the lower-level layout API.

Writes a rendered table to a java.io.Writer, one line per write.

Each line is followed by a single newline. Returns the writer. The table
is rendered eagerly via table; pair with clj-string-layout.core/layout-into!
for streaming behavior on the lower-level layout API.
sourceraw docstring

table-seqclj

(table-seq spec)

Renders a high-level table spec as a sequence of output lines.

This currently applies the high-level table normalization before returning the sequence. Use clj-string-layout.core/layout-seq directly when you need fully streaming behavior with already-normalized rows and explicit column widths.

Renders a high-level table spec as a sequence of output lines.

This currently applies the high-level table normalization before returning the
sequence. Use clj-string-layout.core/layout-seq directly when you need fully
streaming behavior with already-normalized rows and explicit column widths.
sourceraw docstring

table-strclj

(table-str spec)

Renders a high-level table spec and joins the resulting lines with newlines.

Renders a high-level table spec and joins the resulting lines with newlines.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close