Skip to content

Instantly share code, notes, and snippets.

@KSCGroup
Created February 20, 2012 22:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save KSCGroup/1872000 to your computer and use it in GitHub Desktop.
reversed sequence of "(cond...(resolve...(find-ns..." to "(cond...(find-ns...(resolve..." to make doc work with ns, like (doc clojure.core)
(in-ns 'clojure.repl)
(defmacro doc
"Prints documentation for a var or special form given its name"
{:added "1.0"}
[name]
(if-let [special-name ('{& fn catch try finally try} name)]
(#'print-doc (#'special-doc special-name))
(cond
(special-doc-map name) `(#'print-doc (#'special-doc '~name))
(find-ns name) `(#'print-doc (#'namespace-doc (find-ns '~name)))
(resolve name) `(#'print-doc (meta (var ~name)))
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment