Skip to content

Commit 26b4758

Browse files
committed
Tweak the documentation for handle-pprint-fn
1 parent 0ebb9b6 commit 26b4758

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/cider/nrepl.clj

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,8 @@
8181

8282
(def wrap-pprint-fn-optional-arguments
8383
"Common pprint arguments for CIDER's middleware."
84-
{"pprint-fn" "The namespace-qualified name of a single-arity function to use for pretty-printing. Defaults to `clojure.pprint/pprint`."
85-
"print-length" "Value to bind to `*print-length*` when pretty-printing. Defaults to the value bound in the current REPL session."
86-
"print-level" "Value to bind to `*print-level*` when pretty-printing. Defaults to the value bound in the current REPL session."
87-
"print-meta" "Value to bind to `*print-meta*` when pretty-printing. Defaults to the value bound in the current REPL session."
88-
"print-right-margin" "Value to bind to `clojure.pprint/*print-right-margin*` when pretty-printing. Defaults to the value bound in the current REPL session."})
84+
{"pprint-fn" "The namespace-qualified name of a 1 or 2-arity function to use for pretty-printing. Defaults to `cider.nrepl.pprint/pprint`."
85+
"print-params" "A map of configuration entries that the pprint-fn will understand. Those would typically be specific to the pprint-fn in question."})
8986

9087
(def-wrapper wrap-pprint-fn cider.nrepl.middleware.pprint/handle-pprint-fn
9188
(fn [msg] true)
@@ -94,16 +91,18 @@
9491
9592
A namespace-qualified name of the function to be used for printing can
9693
be optionally passed in the `:pprint-fn` slot, the default value being
97-
`clojure.pprint/pprint`.
94+
`cider.nrepl.pprint/pprint`. The function name can be passed as
95+
a string or symbol. Note that function should take 1 or two params - the
96+
object to print and the an optional map of print params. The params should
97+
be passed as `:print-params` - a map of key/value params. If they were passed
98+
by the client as with string keys, this middleware will convert the keys to
99+
keywords.
98100
99-
The `:pprint-fn` slot will be replaced with a closure that calls the
100-
given printing function with `*print-length*`, `*print-level*`,
101-
`*print-meta*`, and `clojure.pprint/*print-right-margin*` bound to the
102-
values of the `:print-length`, `:print-level`, `:print-meta`, and
103-
`:print-right-margin` slots respectively.
101+
The `:pprint-fn` slot will be replaced with the var that maps to the name
102+
that was initially passed.
104103
105104
Middlewares further down the stack can then look up the `:pprint-fn`
106-
slot and call it where necessary."
105+
slot, call it where necessary, and pass it the value of the `:print-params` slot."
107106
:requires #{#'session}
108107
:expects #{"eval" "load-file"}})
109108

0 commit comments

Comments
 (0)