Liking cljdoc? Tell your friends :D

clj-commons.format.table

Formatted tabular output, similar to (but much prettier and more flexible than) clojure.pprint/print-table.

Specs are in [[clj-commons.format.table.specs]].

Formatted tabular output, similar to (but much prettier and more flexible than)
 clojure.pprint/print-table.

Specs are in [[clj-commons.format.table.specs]].
raw docstring

*default-style*clj

Default style used for table output. Defaults to default-style.

Default style used for table output.  Defaults to [[default-style]].
sourceraw docstring

default-styleclj

Default style, with thin borders (using character graphics) and a header and footer.

Default style, with thin borders (using character graphics) and a header and footer.
sourceraw docstring

minimal-styleclj

A minimal style that uses only white-space as a column separator.

A minimal style that uses only white-space as a column separator.
sourceraw docstring

(print-table opts rows)

Similar to clojure.pprint/print-table, but with fancier graphics and more control over column titles.

The rows are a seq of associative values, usually maps.

In simple mode, each column is just a keyword; the column title is derived from the keyword, and the column's width is set to the maximum of the title width and the width of the longest value in the rows.

Alternately, a column can be a map:

KeyTypeDescription
:keykeyword/functionPassed the row data and returns the value for the column (required)
:titleStringThe title for the column
:title-align:right, :left, :centerHow to pad the title column; default is :center
:widthnumberWidth of the column
:formatterfunctionPassed the column value and returns formatted content as a string or composed string
:decoratorfunctionMay return a font declaration for the cell
:align:right, :left, :centerDefaults to :right except for last column, which aligns :left

:key is typically a keyword but can be an arbitrary function (in which case, you must also provide :title). The return value is a composed string (passed to [[compose]]); if returning a composed string, you must also provide an explicit :width.

The default for :title is deduced from :key; when omitted and :key is a keyword; the keyword is converted to a string, capitalized, and embedded dashes converted to spaces.

:width will be determined as the maximum width of the title or of any formatted value in the data.

The decorator is a function; it will be passed the row index and the value for the column, and returns a font declaration (or nil). A font declaration can be a single keyword (.e.g, :red.bold) or a vector of keywords (e.g. [:red :bold]).

opts can be a seq of columns, or it can be a map of options:

KeyTypeDescription
:columnsseq of columnsDescribes the columns to print
:stylemapOverrides the default styling of the table
:default-decoratorfunctionUsed when a column doesn't define its own decorator (deprecated)
:row-annotatorfunctionCan add text immediately after the end of the row
:row-decoratorfunctionDecorates all columns

:default-decorator is only used for columns that do not define their own decorator. This can be used, for example, to alternate the background color of cells.

The :row-decorator is passed the row index (from 0) and the row value and returns a font declaration for all columns of the row. The font declaration for the row wraps around the column-specific font, which wraps around the value.

The :row-annotator is passed the row index and the row data, and returns a composed string that is appended immediately after the end of the row (but outside any border), which can be used to add a note to the right of a row.

Similar to clojure.pprint/print-table, but with fancier graphics and more control
over column titles.

The rows are a seq of associative values, usually maps.

In simple mode, each column is just a keyword; the column title is derived
from the keyword, and the column's width is set to the maximum
of the title width and the width of the longest value in the rows.

Alternately, a column can be a map:

Key          | Type                   | Description
---          |---                     |---
:key         | keyword/function       | Passed the row data and returns the value for the column (required)
:title       | String                 | The title for the column
:title-align | :right, :left, :center | How to pad the title column; default is :center
:width       | number                 | Width of the column
:formatter   | function               | Passed the column value and returns formatted content as a string or composed string
:decorator   | function               | May return a font declaration for the cell
:align       | :right, :left, :center | Defaults to :right except for last column, which aligns :left

:key is typically a keyword but can be an arbitrary function
(in which case, you must also provide :title). The return
value is a composed string (passed to [[compose]]); if returning a composed string,
you must also provide an explicit :width.

The default for :title is deduced from :key; when omitted and :key is a keyword;
the keyword is converted to a string, capitalized, and embedded dashes
converted to spaces.

:width will be determined as the maximum width of the title or of any
formatted value in the data.

The decorator is a function; it will be
passed the row index and the value for the column,
and returns a font declaration (or nil).  A font declaration can be a single keyword
(.e.g, :red.bold) or a vector of keywords (e.g. [:red :bold]).

opts can be a seq of columns, or it can be a map of options:

Key                | Type           | Description
---                |---             |---
:columns           | seq of columns | Describes the columns to print
:style             | map            | Overrides the default styling of the table
:default-decorator | function       | Used when a column doesn't define its own decorator (deprecated)
:row-annotator     | function       | Can add text immediately after the end of the row
:row-decorator     | function       | Decorates all columns

:default-decorator is only used for columns that do not define their own
decorator.  This can be used, for example, to alternate the background color
of cells.

The :row-decorator is passed the row index (from 0) and the row value and returns
a font declaration for all columns of the row.  The font declaration for the row
wraps around the column-specific font, which wraps around the value.

The :row-annotator is passed the row index and the row data,
and returns a composed string that is appended immediately after
the end of the row (but outside any border), which can be used to
add a note to the right of a row.
sourceraw docstring

skinny-styleclj

Removes most of the borders and uses simple characters for column separators.

Removes most of the borders and uses simple characters for column separators.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close