marginalia icon indicating copy to clipboard operation
marginalia copied to clipboard

Docstrings in metadata are extracted, but the metadata key is shown with no value.

Open benjamin-bader opened this issue 11 years ago • 2 comments

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?

benjamin-bader avatar Feb 26 '14 22:02 benjamin-bader

Or perhaps we should just remove :doc from the metadata map...!

benjamin-bader avatar Feb 26 '14 23:02 benjamin-bader

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)))

jcswart avatar Feb 28 '14 00:02 jcswart