Emit open and indent the group's break points indent columns further.
A break point: sep (by default a space) when the enclosing group fits
on one line, else a newline at the group's indentation.
A comment at the end of the current line, printed as // text. It
breaks every group open around it.
A printer for a hole in the document at the current position, which can be written to later: what it prints appears here, laid out as if it had been printed inline. This is how a value whose description is only known once the test uses it (a stub function recording its calls, say) prints. Writes to it do nothing once the test case is over, or when a speculative region around its position was aborted.
beginGroup, then body (given this printer), then
endGroup. Returns what body returns.
A newline at the current indentation.
Text printed only when the enclosing group breaks, such as a trailing comma.
A one-line representation the engine recovers the bracket structure of, so that it wraps like a value printed structurally.
The separator between two items of a group: , and a break point.
Print items between open and close the way built-in containers
print: on one line, separated by , , when they fit, and otherwise one
item per line, indented four columns, each followed by a comma, with
close on a line of its own. (Rust's seq aligns broken items under
open instead; write that layout with group and
separator.)
Shift the indentation of later break points by delta columns.
Open a speculative region: output printed from now on is held back until Speculation.commit keeps it or Speculation.abort discards it. A generator that may retract a draw (a filter's rejected attempt, a duplicate element) prints each attempt speculatively:
const speculation = printer.speculate();
try {
const value = tc.drawAndPrint(source, printer);
if (accepted(value)) speculation.commit();
} finally {
speculation.abort();
}
Literal text. A newline in it starts a new line, as hardBreak does.
Print value as JavaScript syntax: strings double-quoted with JSON
escapes, bigints with their n suffix, -0 kept, and arrays, plain
objects, Maps, Sets, typed arrays and Dates as the expressions
that construct them. Instances of other classes print through their
prettyPrint method, or else as their class name and own
enumerable properties, and a value that contains itself prints the
repeated reference as [Circular].
StaticnoopA printer that discards everything printed to it. A generator drawing silently draws through its printing path with this printer, so that both paths make the same choices.
The write surface of a failure report, laid out by the engine: a group either fits on the current line, every break point in it rendering as its separator, or breaks, every break point starting a new line at the group's indentation.
A generators.PrintableGenerator receives one in doDrawAndPrint, positioned where the value goes, and so do printWith callbacks and prettyPrint methods. PrettyPrinter.noop discards everything, and a Document gives one to print into outside a test.