#lang scribble/doc @begin[(require scribble/manual) (require scribble/eval) (require scribble/basic) (require (for-label "../main.ss")) (require "utils.ss")] @title[#:tag "print"]{Pretty-Printing} This library provides facilities for pretty-printing JavaScript source. It be can required via: @defmodule[(planet dherman/javascript:6/print)] This library depends on the @tt{pprint} PLaneT package, which can be required via: @schemeblock[(require (planet dherman/pprint:4))] See the documentation for @tt{pprint} for information on how to use it. @section[#:tag "format"]{Formatting Terms} @defproc[(format-term (term Term/X?)) doc?]{ Formats a JavaScript term as a @tech{doc} for pretty-printing.} @section[#:tag "format-config"]{Configuration Parameters} @defthing[current-indentation-width (parameter/c natural-number/c)]{The number of spaces to indent.} @defthing[collapse-lines? (parameter/c boolean?)]{(Currently ignored.)} @defthing[collapse-simple-substatements? (parameter/c boolean?)]{Non-block substatements stay on same line?} @section[#:tag "format-extensions"]{Extending the Pretty-Printer} As described in @secref["extensions"], 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 @tech{doc}s. Matchers should simple fail to match (raising the same error as @scheme[(match)] would for anything other than the forms they recognize. @deftogether[ [@defthing[formatters/Expression (parameter/c (listof (any -> doc?)))]{} @defthing[formatters/Statement (parameter/c (listof (any -> doc?)))]{} @defthing[formatters/ExpressionList (parameter/c (listof (any -> doc?)))]{} @defthing[formatters/StatementList (parameter/c (listof (any -> doc?)))]{}]]