package wax-lib

All checked builds pass
  1. Overview
  2. Docs
Libraries for Wax, a Rust-like syntax for WebAssembly

Install

dune-project
 Dependency

Authors

Maintainers

Sources

wax-v0.3.0.tbz
sha256=cc19989d0db930d9300d7356c8f127309424a82767dd3c91ffd19a0bfd20e3a6
sha512=14ff9219dc6c4e8855c3cb895bd1af6fd81d1c521afefe1e7f69208a2e37abc7ec0946f188198a26780aa405fd43a526b938158334a019f7a5d991d8efc437c3

doc/wax-lib.utils/Wax_utils/Styled_printer/index.html

Module Wax_utils.Styled_printerSource

A pretty-printing context pairing a layout Printer.t with a colour Colors.theme and the Trivia (comments, blank lines) to weave back into the output. The styling and trivia plumbing is shared by the Wax and the WebAssembly printers, which wrap this context with their own format-specific state.

Sourcetype t = {
  1. printer : Printer.t;
  2. theme : Colors.theme;
  3. mutable style_override : Colors.style option;
    (*

    When set, every styled atom is rendered in this style instead of its own; used to colour an expression printed inside an attribute. Left None by printers that do not need it.

    *)
  4. trivia : Trivia.t;
  5. seen : Trivia.locations;
  6. collect : Trivia.locations option;
}
Sourceval create : printer:Printer.t -> theme:Colors.theme -> ?collect:Trivia.locations -> trivia:Trivia.t -> unit -> t

Build a context with a fresh seen table and no style_override.

Sourceval print_styled : t -> Colors.style -> ?len:int option -> string -> unit

Emit text wrapped in the theme's escape sequence for the given style — or for the style_override, when one is in effect. len overrides the text's display width.

Sourceval comment : t -> string -> unit

Emit comment text in the comment style.

Sourceval print_trivia : t -> Trivia.entry list -> unit

Emit a list of trivia entries (comments and blank lines).

Sourceval get_trivia : t -> Ast.location option -> Trivia.associated

Look up (and mark as seen) the trivia associated with a location.

Sourceval atomic_node : t -> Ast.location option -> (unit -> unit) -> unit

Emit a node's before trivia, run the body, then its within/after trivia.

Sourceval with_style : t -> Colors.style -> (unit -> unit) -> unit

Run the body with style_override set to the given style; a no-op on the override if one is already in effect.