marginalia
marginalia copied to clipboard
Docstrings in metadata are extracted, but the metadata key is shown with no value.
For example, given the following code:
(def ^{:const true
:doc "this is a thing"}
a-thing {})
marg will correctly identify the docstring and move it to the left, but the resulting code looks like this:
(def ^{:const true
:doc }
a-thing {})
I'm not sure if this is technically "wrong", but it is pretty awkward. Would it be better if the string wasn't extracted at all, in cases like this?
Or perhaps we should just remove :doc from the metadata map...!
Something similar happens when using marginalia with enlive.
The deftemplate form takes a string path to the given html template like this:
(enlive-html/deftemplate index "public/index.html" [tasks page-nums]
...)
The marginalia doc parses out "public/index.html" and places it on the left as if it is a doc string. And removes the string in the source on the right, which is not correct.
My guess is that the parser looks for the first string within a form to use as a doc string perhaps.
EDIT: If anyone else happens upon this a simple macro is a decent fix.
(defmacro deftemplate-marg "Helper macro for using deftemplate with doc strings."
[name doc-str source args & forms]
`(def ~name ~doc-str (net.cgrand.enlive-html/template ~source ~args ~@forms)))