Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
benjamin-bader opened this issue Feb 26, 2014 · 2 comments

Comments

@benjamin-bader
Copy link
Collaborator

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
Copy link
Collaborator Author

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

@jcswart
Copy link

jcswart commented Feb 28, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants