Skip to content

Commit

Permalink
Clean up docs and specs
Browse files Browse the repository at this point in the history
  • Loading branch information
hlship committed Apr 26, 2024
1 parent 2bf7681 commit a9f7ad2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/clj_commons/format/table.clj
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
: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
:decorator | function | May return a font declaration for the cell
:pad | :left, :right, :both | Defaults to :left except for last column, which pads on the right
:key is typically a keyword but can be an arbitrary function
(in which case, you must also provide :title). The return
Expand All @@ -124,7 +124,8 @@
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).
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:
Expand Down
10 changes: 7 additions & 3 deletions src/clj_commons/format/table/specs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@
::pad]))

(s/def ::pad #{:left :right})

A
(s/def ::key ifn?)
(s/def ::title string?)
(s/def ::width (s/and int? pos?))
(s/def ::font-declaration (s/or
:keyword keyword?
:vector (s/coll-of (s/nilable keyword?)
:kind vector?)))
(s/def ::decorator (s/fspec
:args (s/cat
:index int?
:value any?)
:ret (s/nilable keyword?)))
(s/def ::default-decorator ::decorator)
:ret (s/nilable ::font-declarationse)))
(s/def ::default-decorator ::decorator)

0 comments on commit a9f7ad2

Please sign in to comment.