github-tui/lib/pretty.mli

32 lines
930 B
OCaml

(** A type representing a structured document. *)
type doc
(** Create a single chunk of string without formatting. *)
val str : string -> doc
(** Create a single chunk of string with formatting. *)
val fmt : Line.styles -> string -> doc
(** Put all documents in a list horizontally, automatically adding required padding. *)
val horizontal : doc list -> doc
(** Put all documents in a list vertically after each other with a line separator. *)
val vertical : doc list -> doc
(** Fill all the empty horizontal space with spaces. Useful for alignment.
Only one [horizontal_fill] is allowed per [horizontal] element. The first one
will be used, the remaining ones will be ignored.
*)
val horizontal_fill : doc
(** Render the resulting document.
Parameters:
* [width]: the max allowed width for the document. Passed recursively and
currently only used for [horizontal_fill].
*)
val render : width:int -> doc -> string