Liking cljdoc? Tell your friends :D

lambdaisland.deep-diff2.puget.printer

Enhanced printing functions for rendering Clojure values. The following options are available to control the printer:

General Rendering

:width

Number of characters to try to wrap pretty-printed forms at.

:print-meta

If true, metadata will be printed before values. Defaults to the value of *print-meta* if unset.

Collection Options

:sort-keys

Print maps and sets with ordered keys. If true, the pretty printer will sort all unordered collections before printing. If a number, counted collections will be sorted if they are smaller than the given size. Otherwise collections are printed in their natural sort order. Sorted collections are always printed in their natural sort order.

:map-delimiter

The text placed between key-value pairs in a map.

:map-coll-separator

The text placed between a map key and a collection value. The keyword :line will cause line breaks if the whole map does not fit on a single line.

:namespace-maps

Extract common keyword namespaces from maps using the namespace map literal syntax. See *print-namespace-maps*.

:seq-limit

If set to a positive number, then lists will only render at most the first n elements. This can help prevent unintentional realization of infinite lazy sequences.

Color Options

:print-color

When true, ouptut colored text from print functions.

:color-markup

:ansi for ANSI color text (the default) :html-inline for inline-styled html :html-classes to use the names of the keys in the :color-scheme map as class names for spans so styling can be specified via CSS.

:color-scheme

Map of syntax element keywords to color codes.

Type Handling

:print-handlers

A lookup function which will return a rendering function for a given class type. This will be tried before the built-in type logic. See the lambdaisland.deep-diff2.puget.dispatch namespace for some helpful constructors. The returned function should accept the current printer and the value to be rendered returning a format document.

:print-fallback

Keyword argument specifying how to format unknown values. Puget supports a few different options:

  • :pretty renders values with the default colored representation.
  • :print defers to the standard print method by rendering unknown values using pr-str.
  • :error will throw an exception when types with no defined handler are encountered.
  • A function value will be called with the current printer options and the unknown value and is expected to return a formatting document representing it.
Enhanced printing functions for rendering Clojure values. The following
options are available to control the printer:

#### General Rendering

`:width`

Number of characters to try to wrap pretty-printed forms at.

`:print-meta`

If true, metadata will be printed before values. Defaults to the value of
`*print-meta*` if unset.

#### Collection Options

`:sort-keys`

Print maps and sets with ordered keys. If true, the pretty printer will sort
all unordered collections before printing. If a number, counted collections
will be sorted if they are smaller than the given size. Otherwise
collections are printed in their natural sort order. Sorted collections are
always printed in their natural sort order.

`:map-delimiter`

The text placed between key-value pairs in a map.

`:map-coll-separator`

The text placed between a map key and a collection value. The keyword :line
will cause line breaks if the whole map does not fit on a single line.

`:namespace-maps`

Extract common keyword namespaces from maps using the namespace map literal
syntax. See `*print-namespace-maps*`.

`:seq-limit`

If set to a positive number, then lists will only render at most the first n
elements. This can help prevent unintentional realization of infinite lazy
sequences.

#### Color Options

`:print-color`

When true, ouptut colored text from print functions.

`:color-markup`

:ansi for ANSI color text (the default)
:html-inline for inline-styled html
:html-classes to use the names of the keys in the :color-scheme map
as class names for spans so styling can be specified via CSS.

`:color-scheme`

Map of syntax element keywords to color codes.

#### Type Handling

`:print-handlers`

A lookup function which will return a rendering function for a given class
type. This will be tried before the built-in type logic. See the
`lambdaisland.deep-diff2.puget.dispatch` namespace for some helpful constructors. The returned
function should accept the current printer and the value to be rendered
returning a format document.

`:print-fallback`

Keyword argument specifying how to format unknown values. Puget supports a few
different options:

- `:pretty` renders values with the default colored representation.
- `:print` defers to the standard print method by rendering unknown values
  using `pr-str`.
- `:error` will throw an exception when types with no defined handler are
  encountered.
- A function value will be called with the current printer options and the
  unknown value and is expected to return a formatting document representing
  it.
raw docstring

*options*clj/s

Default options to use when constructing new printers.

Default options to use when constructing new printers.
sourceraw docstring

canonical-printerclj/s

(canonical-printer)
(canonical-printer handlers)

Constructs a new canonical printer with the given handler dispatch.

Constructs a new canonical printer with the given handler dispatch.
sourceraw docstring

clojure-handlersclj/s

Map of print handlers for 'primary' Clojure types. These should take precedence over the handlers in clojure-interface-handlers.

Map of print handlers for 'primary' Clojure types. These should take
precedence over the handlers in `clojure-interface-handlers`.
sourceraw docstring

clojure-interface-handlersclj/s

Fallback print handlers for other Clojure interfaces.

Fallback print handlers for other Clojure interfaces.
sourceraw docstring

color-textclj/s

(color-text element text)
(color-text options element text)

Produces text colored according to the active color scheme. This is mostly useful to clients which want to produce output which matches data printed by Puget, but which is not directly printed by the library. Note that this function still obeys the :print-color option.

Produces text colored according to the active color scheme. This is mostly
useful to clients which want to produce output which matches data printed by
Puget, but which is not directly printed by the library. Note that this
function still obeys the `:print-color` option.
sourceraw docstring

common-handlersclj/s

Print handler dispatch combining Java and Clojure handlers with inheritance lookups. Provides a similar experience as the standard Clojure pretty-printer.

Print handler dispatch combining Java and Clojure handlers with inheritance
lookups. Provides a similar experience as the standard Clojure
pretty-printer.
sourceraw docstring

cprintclj/s

(cprint value)
(cprint value opts)

Like pprint, but turns on colored output.

Like pprint, but turns on colored output.
sourceraw docstring

cprint-strclj/s

(cprint-str value)
(cprint-str value opts)

Pretty-prints a value to a colored string.

Pretty-prints a value to a colored string.
sourceraw docstring

format-docclj/s

(format-doc printer value)

Recursively renders a print document for the given value.

Recursively renders a print document for the given value.
sourceraw docstring

format-doc*clj/s

(format-doc* printer value)

Formats a document without considering metadata.

Formats a document without considering metadata.
sourceraw docstring

format-unknownclj/s

(format-unknown printer value)
(format-unknown printer value repr)
(format-unknown printer value tag repr)

Renders common syntax doc for an unknown representation of a value.

Renders common syntax doc for an unknown representation of a value.
sourceraw docstring

get-identity-hashcodeclj/s

(get-identity-hashcode o)

Get the hashcode for a given object o

Get the hashcode for a given object o
sourceraw docstring

get-type-nameclj/s

(get-type-name x)

Get the type of the given object as a string. For Clojure, gets the name of the class of the object. For ClojureScript, gets either the name attribute or the protocol name if the name attribute doesn't exist.

Get the type of the given object as a string. For Clojure, gets the name of
the class of the object. For ClojureScript, gets either the `name` attribute
or the protocol name if the `name` attribute doesn't exist.
sourceraw docstring

inst-patternclj/s

source

merge-optionsclj/s

(merge-options a b)

Merges maps of printer options, taking care to combine the color scheme correctly.

Merges maps of printer options, taking care to combine the color scheme
correctly.
sourceraw docstring

platform-handlersclj/s

Map of print handlers for Java/JavaScript types. This supports syntax for regular expressions, dates, UUIDs, and futures.

Map of print handlers for Java/JavaScript types. This supports syntax for regular
expressions, dates, UUIDs, and futures.
sourceraw docstring

pprintclj/s

(pprint value)
(pprint value opts)

Pretty-prints a value to out. Options may be passed to override the default options map.

Pretty-prints a value to *out*. Options may be passed to override the
default *options* map.
sourceraw docstring

pprint-strclj/s

(pprint-str value)
(pprint-str value opts)

Pretty-print a value to a string.

Pretty-print a value to a string.
sourceraw docstring

pr-handlerclj/s

(pr-handler printer value)

Print handler which renders the value with pr-str.

Print handler which renders the value with `pr-str`.
sourceraw docstring

pretty-printerclj/s

(pretty-printer opts)

Constructs a new printer from the given configuration.

Constructs a new printer from the given configuration.
sourceraw docstring

render-outclj/s

(render-out printer value)
(render-out printer value opts)

Prints a value using the given printer.

Prints a value using the given printer.
sourceraw docstring

render-strclj/s

(render-str printer value)

Renders a value to a string using the given printer.

Renders a value to a string using the given printer.
sourceraw docstring

tagged-handlerclj/s

(tagged-handler tag value-fn)

Generates a print handler function which renders a tagged-literal with the given tag and a value produced by calling the function.

Generates a print handler function which renders a tagged-literal with the
given tag and a value produced by calling the function.
sourceraw docstring

to-hex-stringclj/s

(to-hex-string input-string)

Returns a hex representation of input-string

Returns a hex representation of input-string
sourceraw docstring

unknown-handlerclj/s

(unknown-handler printer value)

Print handler which renders the value using the printer's unknown type logic.

Print handler which renders the value using the printer's unknown type logic.
sourceraw docstring

utc-datecljs

(utc-date date)
source

utc-timestamp-formatclj

(utc-timestamp-format)
source

with-colorclj/smacro

(with-color & body)

Executes the given expressions with colored output enabled.

Executes the given expressions with colored output enabled.
sourceraw docstring

with-optionsclj/smacro

(with-options opts & body)

Executes the given expressions with a set of options merged into the current option map.

Executes the given expressions with a set of options merged into the current
option map.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close