package merlin-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=b0dcad092aaaf7a23f65ab9a089e8761bd665cc72357909e0ac6c2182f4fc2d4
sha512=9987baf2b2e82bab4c90a328bfcba9945e797e0f3d947156f04435ee84b49542844b379e35a79027c3ffe81f4b7a8f1c60803233999b4c039d4598033371880d
doc/merlin-lib.utils/Merlin_utils/Format_doc/index.html
Module Merlin_utils.Format_doc
Source
Composable document for the Format
formatting engine.
This module introduces a pure and immutable document type which represents a sequence of formatting instructions to be printed by a formatting engine at later point. At the same time, it also provides format string interpreter which produces this document type from format string and their associated printers.
The module is designed to be source compatible with code defining format printers: replacing `Format` by `Format_doc` in your code will convert `Format` printers to `Format_doc` printers.
Compatibility API
The functions and types below provides source compatibility with format printers and conversion function from Format_doc
printers to Format
printers. The reverse direction is implemented using an escape hatch in the formatting instruction and should only be used to preserve backward compatibility.
formatter rdoc
creates a formatter
that updates the rdoc
reference
Translate a Format_doc
printer to a Format
one.
If necessary, embbed a Format
printer inside a formatting instruction stream. This breaks every guarantees provided by Format_doc
.
Format string interpreters
doc_printf
and kdoc_printf
creates a document directly
Compatibility with Doc
Source compatibility with Format
String printers
Primitive type printers
Printer combinators
Boxes and tags
Break hints
Tabulations
Newlines and flushing
Compiler specific functions
Separators
Compiler output
val pp_two_columns :
?sep:string ->
?max_lines:int ->
formatter ->
(string * string) list ->
unit
pp_two_columns ?sep ?max_lines ppf l
prints the lines in l
as two columns separated by sep
("|" by default). max_lines
can be used to indicate a maximum number of lines to print -- an ellipsis gets inserted at the middle if the input has too many lines.
Example:
pp_two_columns ~max_lines:3 Format.std_formatter [ "abc", "hello"; "def", "zzz"; "a" , "bllbl"; "bb" , "dddddd"; ]
prints
abc | hello ... bb | dddddd