From 5db83e6a4b81b571d828c17c4bbebe58995587c2 Mon Sep 17 00:00:00 2001 From: Stuart Sierra Date: Sun, 19 Dec 2010 10:59:37 -0500 Subject: Copy private print-doc from clojure.repl --- .../src/main/clojure/clojure/contrib/ns_utils.clj | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/ns-utils/src/main/clojure/clojure/contrib/ns_utils.clj b/modules/ns-utils/src/main/clojure/clojure/contrib/ns_utils.clj index 592d7ccc..333a67d2 100644 --- a/modules/ns-utils/src/main/clojure/clojure/contrib/ns_utils.clj +++ b/modules/ns-utils/src/main/clojure/clojure/contrib/ns_utils.clj @@ -67,6 +67,28 @@ (doseq [item (ns-vars ns)] (println item))) +(defn- print-doc [m] + (println "-------------------------") + (println (str (when-let [ns (:ns m)] (str (ns-name ns) "/")) (:name m))) + (cond + (:forms m) (doseq [f (:forms m)] + (print " ") + (prn f)) + (:arglists m) (prn (:arglists m))) + (if (:special-form m) + (do + (println "Special Form") + (println " " (:doc m)) + (if (contains? m :url) + (when (:url m) + (println (str "\n Please see http://clojure.org/" (:url m)))) + (println (str "\n Please see http://clojure.org/special_forms#" + (:name m))))) + (do + (when (:macro m) + (println "Macro")) + (println " " (:doc m))))) + (defn print-docs "Prints documentation for the public vars in a namespace" [ns] -- cgit v1.2.3-18-g5258