Open devurandom opened 1 month ago
I looked at https://github.com/dm3/clojure.java-time/blob/cd06539014adc9b5d99f68820b371b52be6a5657/test/java_time/dev/gen.clj#L193-L217 and after some experimentation on the REPL I believe this might work:
(deftype DocString [value])
(defmethod print-method DocString
[^DocString this ^Writer w]
(.write w (str "\"" (.-value this) "\"")))
With this, the following code (modelled after java-time.dev.gen/print-form
):
(with-bindings {#'*print-meta* true}
(println (pr-str (with-meta {:value "X"} {:doc (DocString. "multi\nline\nstring")}))))
prints:
^{:doc "multi
line
string"} {:value "X"}
The docstrings in
java-time.api
contain literal\n
instead of newlines, which makes them hard to read in code. Cursive does not display them nicely either, but shows the documentation with the literal\n
.