diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/boot.clj | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/clj/clojure/boot.clj b/src/clj/clojure/boot.clj index 283f0b04..4645abf3 100644 --- a/src/clj/clojure/boot.clj +++ b/src/clj/clojure/boot.clj @@ -2409,10 +2409,36 @@ (re-find (re-matcher re (str (:name ^v))))))] (print-doc v))))) +(defn special-form-anchor + "Returns the anchor tag on http://clojure.org/special_forms for the + special form x, or nil" + [x] + (#{'. 'def 'do 'fn 'if 'let 'loop 'monitor-enter 'monitor-exit 'new + 'quote 'recur 'set! 'throw 'try 'var} x)) + +(defn syntax-symbol-anchor + "Returns the anchor tag on http://clojure.org/special_forms for the + special form that uses syntax symbol x, or nil" + [x] + ({'& 'fn 'catch 'try 'finally 'try} x)) + +(defn print-special-doc + [name type anchor] + (println "-------------------------") + (println name) + (println type) + (println (str " Please see http://clojure.org/special_forms#" anchor))) + (defmacro doc - "Prints documentation for the var named by varname" - [varname] - `(print-doc (var ~varname))) + "Prints documentation for a var or special form given its name" + [name] + (cond + (special-form-anchor `~name) + `(print-special-doc '~name "Special Form" (special-form-anchor '~name)) + (syntax-symbol-anchor `~name) + `(print-special-doc '~name "Syntax Symbol" (syntax-symbol-anchor '~name)) + :else + `(print-doc (var ~name)))) (defn tree-seq "returns a lazy sequence of the nodes in a tree, via a depth-first walk. |