module Easy_format:Easy_format: indentation made easy.sig
..end
Input data must be first modelled as a tree using 3 kinds of nodes:
typewrap =
[ `Always_wrap | `Force_breaks | `Never_wrap | `No_breaks | `Wrap_atoms ]
`Wrap_atoms
: wrap if the list contains only atoms`Always_wrap
: always wrap when needed`Never_wrap
: never wrap,
i.e. the list is either horizontal or vertical`Force_breaks
: align vertically,
i.e. always break line between list items and
align the left edge of each item.`No_breaks
: align horizontally,
i.e. never break line between list itemstypestyle_name =
string
type
style = {
|
tag_open : |
|
tag_close : |
type
atom_param = {
|
atom_style : |
(* | Default: None | *) |
val atom : atom_param
type
list_param = {
|
space_after_opening : |
(* | Whether there must be some whitespace
after the opening string.
Default: true | *) |
|
space_after_separator : |
(* | Whether there must be some whitespace
after the item separators.
Default: true | *) |
|
space_before_separator : |
(* | Whether there must be some whitespace
before the item separators.
Default: false | *) |
|
separators_stick_left : |
(* | Whether the separators must
stick to the item on the left.
Default: true | *) |
|
space_before_closing : |
(* | Whether there must be some whitespace
before the closing string.
Default: true | *) |
|
stick_to_label : |
(* | Whether the opening string should be fused
with the preceding label.
Default: true | *) |
|
align_closing : |
(* | Whether the beginning of the
closing string must be aligned
with the beginning of the opening string
(stick_to_label = false) or
with the beginning of the label if any
(stick_to_label = true).
Default: true | *) |
|
wrap_body : |
(* | Defines under which conditions the list body
may be wrapped, i.e. allow several lines
and several list items per line.
Default: `Wrap_atom_list | *) |
|
indent_body : |
(* | Extra indentation of the list body.
Default: 2 | *) |
|
list_style : |
(* | Default: None | *) |
|
opening_style : |
(* | Default: None | *) |
|
body_style : |
(* | Default: None | *) |
|
separator_style : |
(* | Default: None | *) |
|
closing_style : |
(* | Default: None | *) |
Easy_format.list
.val list : list_param
In order to make code compatible with future versions of the library,
the record inheritance syntax should be used, e.g.
{ list with align_closing = false }
.
If new record fields are added, the program would still compile
and work as before.
type
label_param = {
|
space_after_label : |
(* | Whether there must be some whitespace
after the label.
Default: true | *) |
|
indent_after_label : |
(* | Extra indentation before the item
that comes after a label.
Default: 2 | *) |
|
label_style : |
(* | Default: None | *) |
Easy_format.label
.val label : label_param
In order to make code compatible with future versions of the library,
the record inheritance syntax should be used, e.g.
{ label with indent_after_label = 0 }
.
If new record fields are added, the program would still compile
and work as before.
type
t =
| |
Atom of |
(* | Plain string normally without line breaks. | *) |
| |
List of |
(* | List ((opening, separator, closing, param), nodes) | *) |
| |
Label of |
(* | Label ((label, param), node) : labelled node. | *) |
| |
Custom of |
(* | User-defined printing function that allows to use the Format module directly if necessary. It is responsible for leaving the formatter in a clean state. | *) |
Detail of a list node
List ((opening, separator, closing, param), nodes)
:
opening
: opening string such as "{"
"["
"("
"begin"
""
etc.separator
: node separator such as ";"
","
""
"+"
"|"
etc.closing
: closing string such as "}"
"]"
")"
"end"
""
etc.nodes
: elements of the list.typeescape =
[ `Escape of (string -> int -> int -> unit) -> string -> int -> int -> unit
| `Escape_string of string -> string
| `None ]
typestyles =
(style_name * style) list
module Pretty:sig
..end
module Compact:sig
..end
Custom
printing.