package ocamlformat-lib
Module Ocamlformat_lib.FmtSource
Formatting combinators
type s =
(Ocamlformat_stdlib.unit, Format_.formatter, Ocamlformat_stdlib.unit)
Ocamlformat_stdlib.formatFormat strings that accept no arguments.
Format thunks.
type sp = | Blank(*
*)| Cut(*
*)@,| Space(*
*)@| Break of Ocamlformat_stdlib.int * Ocamlformat_stdlib.int(*
*)@;
Format concatenation of n elements.
Pre-compose a format thunk onto a function returning a format thunk.
Defer the evaluation of some side effects until formatting happens.
Set the margin.
Set the maximum indentation.
eval fs t runs format thunk t outputting to fs
Catch exceptions raised while formatting.
Break hints and format strings --------------------------------------
Format a break hint.
val cbreak :
fits:
(Ocamlformat_stdlib.string
* Ocamlformat_stdlib.int
* Ocamlformat_stdlib.string) ->
breaks:
(Ocamlformat_stdlib.string
* Ocamlformat_stdlib.int
* Ocamlformat_stdlib.string) ->
tFormat a custom break.
fits = (a, b, c)formats a stringa,bspaces and a stringcif the line does not break.breaks = (d, e, f)formats a stringd,espaces and a stringfif the line breaks.
Primitive types -----------------------------------------------------
Format a char.
Format a string.
Primitive containers ------------------------------------------------
Format an option using provided formatter for the element.
Format a list separated by a format string using provided function for the elements.
val list_fl :
'a Ocamlformat_stdlib.list ->
(first:Ocamlformat_stdlib.bool -> last:Ocamlformat_stdlib.bool -> 'a -> t) ->
tFormat a list using provided function for the elements, which is passed the flags indicating if the element is the first or last.
val list_pn :
'a Ocamlformat_stdlib.list ->
(prev:'a Ocamlformat_stdlib.option ->
'a ->
next:'a Ocamlformat_stdlib.option ->
t) ->
tFormat a list using provided function for the elements, which is passed the previous and next elements, if any.
Format a list using the format thunk for the separators between elements.
Conditional formatting ----------------------------------------------
Conditionally format.
Conditionally format thunk.
Conditionally select between two format strings.
Conditionally select between two format thunks.
Optionally format. fmt_opt (Some t) is t and fmt_opt None is noop.
Conditional on immediately following a line break -------------------
Format a string if the line has just been broken.
Format a break unless the line has just been broken.
Conditional on breaking of enclosing box ----------------------------
val fits_breaks :
?force:behavior ->
?hint:(Ocamlformat_stdlib.int * Ocamlformat_stdlib.int) ->
?level:Ocamlformat_stdlib.int ->
Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.string ->
tfits_breaks fits nspaces offset breaks prints fits if the enclosing box fits on one line, and otherwise prints breaks, which is a string that optionally follows a break hint (that is a pair (nspaces, offset) equivalent to the break hint "@;<nspaces offset>").
val fits_breaks_if :
?force:behavior ->
?hint:(Ocamlformat_stdlib.int * Ocamlformat_stdlib.int) ->
?level:Ocamlformat_stdlib.int ->
Ocamlformat_stdlib.bool ->
Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.string ->
tAs fits_breaks, but conditional.
Wrapping ------------------------------------------------------------
wrap prologue epilogue body formats prologue then body then epilogue.
As wrap, but prologue and epilogue may be arbitrary format thunks.
As wrap, but prologue and epilogue are only formatted conditionally.
As wrap_if, but prologue and epilogue may be arbitrary format thunks.
val wrap_if_fits_or :
Ocamlformat_stdlib.bool ->
Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.string ->
t ->
tAs wrap_if_fits, but prologue and epilogue can be forced by the additional condition.
val wrap_fits_breaks :
?space:Ocamlformat_stdlib.bool ->
Conf.t ->
Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.string ->
t ->
tAs wrap, but if space is provided, a space is added after prologue and a space hint is added before epilogue in case the enclosing box breaks.
val wrap_fits_breaks_if :
?space:Ocamlformat_stdlib.bool ->
Conf.t ->
Ocamlformat_stdlib.bool ->
Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.string ->
t ->
tAs wrap_fits_breaks, but prologue and epilogue are formatted subject to the additional condition.
Boxes ---------------------------------------------------------------
Represent boxes inside a format thunk with colored brackets. For debug purposes
Open an vbox with specified indentation.
Open an hvbox with specified indentation.
Open an hovbox with specified indentation.
Wrapping boxes ------------------------------------------------------
Wrap a format thunk with a compacting box with specified indentation.
Wrap a format thunk with a vbox with specified indentation.
Wrap a format thunk with an hvbox with specified indentation.
Wrap a format thunk with an hovbox with specified indentation.
val cbox_if :
?name:Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.bool ->
Ocamlformat_stdlib.int ->
t ->
tConditionally wrap a format thunk with a compacting sbox with specified indentation.
val vbox_if :
?name:Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.bool ->
Ocamlformat_stdlib.int ->
t ->
tConditionally wrap a format thunk with a vbox with specified indentation.
val hvbox_if :
?name:Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.bool ->
Ocamlformat_stdlib.int ->
t ->
tConditionally wrap a format thunk with an hvbox with specified indentation.
val hovbox_if :
?name:Ocamlformat_stdlib.string ->
Ocamlformat_stdlib.bool ->
Ocamlformat_stdlib.int ->
t ->
tConditionally wrap a format thunk with an hovbox with specified indentation.
Text filling --------------------------------------------------------
Format a non-empty string as filled text wrapped at the margin.