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-styleclj

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

Default style, with thick borders (using character graphics) and a header and footer.
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-pad:left, :right, :bothHow to pad the title column; default is :both to center the title
:widthnumberWidth of the column
:decoratorfunctionMay return a font keyword for the cell
:pad:left, :right, :bothDefaults to :left except for last column

: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 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 keyword (or nil).

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 it own decorator
:row-annotatorfunctionCan add text immediately after the end of the row

: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-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-pad | :left, :right, :both | How to pad the title column; default is :both to center the title
:width     | number               | Width of the column
:decorator | function             | May return a font keyword for the cell
:pad       | :left, :right, :both | Defaults to :left except for last column

: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
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 keyword (or nil).

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 it own decorator
:row-annotator     | function       | Can add text immediately after the end of the row

: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-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