On this page:
top
up

4Pretty-PrintingπŸ”— i

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

This library depends on the pprint package, which can be required via:

(require pprint)

See the documentation for pprint for information on how to use it.

4.1Formatting TermsπŸ”— i

procedure

( format-term term)doc?

term:Term/X?
Formats any JavaScript term as a doc for pretty-printing.

procedure

( format-source-element element)doc?

element:SourceElement?
Formats a JavaScript source element as a doc for pretty-printing.

procedure

( format-variable-initializer init)doc?

Formats a variable initializer as a doc for pretty-printing.

procedure

( format-declaration decl)doc?

Formats a declaration as a doc for pretty-printing.

procedure

( format-expression expr)doc?

Formats an expression as a doc for pretty-printing.

procedure

( format-subexpression exprparent)doc?

parent:Expression?
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.

procedure

( format-statement stmt)doc?

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.

procedure

( format-nested-substatement stmt)doc?

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.

procedure

( format-substatement stmt)doc?

Formats a statement that occurs as a substatement as a doc for pretty-printing.

procedure

( format-case-clause clause)doc?

clause:CaseClause?
Formats a case clause as a doc for pretty-printing.

procedure

( format-property property)doc?

property:Property?
Formats an object property as a doc for pretty-printing.

procedure

( format-identifier id)doc?

Formats an identifier as a doc for pretty-printing.

4.2Configuration ParametersπŸ”— i

The number of spaces to indent.
(Currently ignored.)
Non-block substatements stay on same line?

4.3Extending the Pretty-PrinterπŸ”— i

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.

procedure

( format-map feltsparam)c

f:(a-> c)
elts:(or (listof a)b)
param:(parameter/c (b-> c))
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.

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /