Version: 4.1.5.3
4 Pretty-Printing
This library provides facilities for pretty-printing JavaScript source. It can be
required via:
This library depends on the pprint PLaneT package, which can be required via:
(require (planet dherman/pprint:4))
See the documentation for pprint for information on how to use it.
4.1 Formatting Terms
Formats any JavaScript term as a doc for pretty-printing.
Formats a JavaScript source element as a doc for pretty-printing.
Formats a variable initializer as a doc for pretty-printing.
Formats a declaration as a doc for pretty-printing.
Formats an expression as a doc for pretty-printing.
Formats an expression expr that occurs as an immediate subexpression of parent
as a doc for pretty-printing. The parenthesization is determined based on the precedence
of the two expressions.
Formats a statement as a doc for pretty-printing.
Post-conditions: The statement output includes its own semicolon if appropriate,
and statement output is not newline-terminated.
Formats a statement that occurs as an indented substatement as a doc for pretty-printing.
Post-condition: The indentation level is returned to its previous level after the
substatement.
Formats a statement that occurs as a substatement as a doc for pretty-printing.
Formats a case clause as a doc for pretty-printing.
Formats an object property as a doc for pretty-printing.
Formats an identifier as a doc for pretty-printing.
4.2 Configuration Parameters
The number of spaces to indent.
(Currently ignored.)
Non-block substatements stay on same line?
4.3 Extending the Pretty-Printer
As described in Extending the Language, it is possible to extend the language with custom forms.
The pretty-printer can be extended with extra matchers that recognize just their form types and
produce pretty-printed docs. Matchers should simple fail to match (raising the same error
as (match) would for anything other than the forms they recognize.
Applies a formatter to an extensible list of terms (such as an ExpressionList/X or StatementList/X).
If the formatter fails to match, the current value of the param parameter is used to format the elements
instead.