On this page:
4.1 Formatting Terms
format-term
4.2 Configuration Parameters
current-indentation-width
collapse-lines?
collapse-simple-substatements?
4.3 Extending the Pretty-Printer
formatters/ Expression
formatters/ Statement
formatters/ Expression List
formatters/ Statement List
Version: 4.1.0.2

4 Pretty-Printing

This library provides facilities for pretty-printing JavaScript source. It be can required via:

 (require (planet dherman/javascript:6/print))

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

(format-term term)  doc?

  term : Term/X?

Formats a JavaScript term as a doc for pretty-printing.

4.2 Configuration Parameters

current-indentation-width : (parameter/c natural-number/c)

The number of spaces to indent.

collapse-lines? : (parameter/c boolean?)

(Currently ignored.)

collapse-simple-substatements? : (parameter/c boolean?)

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.

formatters/Expression : (parameter/c (listof (any -> doc?)))

formatters/Statement : (parameter/c (listof (any -> doc?)))

formatters/ExpressionList : (parameter/c (listof (any -> doc?)))

formatters/StatementList : (parameter/c (listof (any -> doc?)))