reversed sequence of "(cond...(resolve...(find-ns..." to "(cond...(find-ns...(resolve..." to make doc work with ns, like (doc clojure.core)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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