Module Pplumbing_pp_tty.Pp_tty

Build pretty printed documents for the user.

module Ansi_color : sig ... end

Build pretty printed documents with ansi colors.

module Style : sig ... end

Symbolic styles that can be used inside messages. These styles are later converted to actual concrete styles depending on the output device. For instance, when printed to the terminal they are converted to ansi terminal styles (Ansi_color.Style.t list values).

type t = Style.t Pp.t

Styled document that can be printed to the console or in the log file.

module Print_config : sig ... end
val print : ?config:Print_config.t -> t -> unit

Print to stdout (not thread safe)

val prerr : ?config:Print_config.t -> t -> unit

Print to stderr (not thread safe)

val pp : Stdlib.Format.formatter -> t -> unit

Render a styled document to a formatter, resolving symbolic styles to ANSI escape sequences using the default print config.

val to_string : t -> string

Render a styled document to a string with ANSI escape sequences using the default print config.

val pp_with_config : config:Print_config.t -> Stdlib.Format.formatter -> t -> unit

Same as pp but with a custom print config.

val to_string_with_config : config:Print_config.t -> t -> string

Same as to_string but with a custom print config.

val sexp : Sexplib0.Sexp.t -> t

Embed a Sexp.t value, preserving the original structure for round-tripping while rendering it as a human-readable string.

val dyn : Dyn.t -> t

Embed a Dyn.t value, preserving the original structure for round-tripping while rendering it as a human-readable string.

val tag : Style.t -> t -> t

An alias for Pp.tag dedicated to the expected Style.t type. Using this function allows to write the Style.t constructor without qualifying them, which may be more ergonomic.

Basic helpers

val parens : 'a Pp.t -> 'a Pp.t
val brackets : 'a Pp.t -> 'a Pp.t
val braces : 'a Pp.t -> 'a Pp.t
val simple_quotes : 'a Pp.t -> 'a Pp.t
val double_quotes : 'a Pp.t -> 'a Pp.t

Opinionated helpers

val loc : Loc.t -> t

A pretty printer for code locations. The uses a common syntax that is usually configured by editors to allow jumping to locations. If the file listed by the location is available, this will render a small quotation for the location, such as in:

  File "my-file", line 42, character 6-11:
  42 | Hello World
             ^^^^^
module type To_string = sig ... end
val id : (module To_string with type t = 'a) -> 'a -> t

A modular-explicit helper that uses brackets and the Id symbolic style to format a stringable identifier.

val kwd : (module To_string with type t = 'a) -> 'a -> t

A modular-explicit helper that uses brackets and the Kwd symbolic style to format a stringable keyword.

val path : (module To_string with type t = 'a) -> 'a -> t

A modular-explicit helper that uses double_quotes and the Bold ansi style to format a stringable path.

val ansi : (module To_string with type t = 'a) -> 'a -> Ansi_color.Style.t list -> t

A modular-explicit helper that uses the ansi style to format a stringable variable.

Private

This module is exported to be used by libraries with strong ties to pplumbing-pp-tty and by tests. Its signature may change in breaking ways at any time without prior notice, and outside of the guidelines set by semver.

Do not use.

module Private : sig ... end