diff options
Diffstat (limited to 'src/clojure/contrib/pprint/examples/show_doc.clj')
-rw-r--r-- | src/clojure/contrib/pprint/examples/show_doc.clj | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/clojure/contrib/pprint/examples/show_doc.clj b/src/clojure/contrib/pprint/examples/show_doc.clj new file mode 100644 index 00000000..e5897ce6 --- /dev/null +++ b/src/clojure/contrib/pprint/examples/show_doc.clj @@ -0,0 +1,42 @@ +; Copyright (c) Tom Faulhaber, Dec 2008. All rights reserved. +; The use and distribution terms for this software are covered by the +; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +; which can be found in the file epl-v10.html at the root of this distribution. +; By using this software in any fashion, you are agreeing to be bound by +; the terms of this license. +; You must not remove this notice, or any other, from this software. + +(ns clojure.contrib.pprint.examples.show-doc + (:use clojure.contrib.pprint)) + +(defn ns-list + ([] (ns-list nil)) + ([pattern] + (filter + (if pattern + (comp (partial re-find pattern) name ns-name) + (constantly true)) + (sort-by ns-name (all-ns))))) + +(defn show-doc + ([] (show-doc nil)) + ([pattern] + (cl-format + true + "~:{~A: ===============================================~ + ~%~{~{~a: ~{~a~^, ~}~%~a~%~}~^~%~}~2%~}" + (map + #(vector (ns-name %) + (map + (fn [f] + (let [f-meta ^(find-var (symbol (str (ns-name %)) (str f)))] + [f (:arglists f-meta) (:doc f-meta)])) + (filter + (fn [a] (instance? clojure.lang.IFn a)) + (sort (map key (ns-publics %)))))) + (ns-list pattern))))) + +(defn create-api-file [pattern out-file] + (with-open [f (java.io.FileWriter. out-file)] + (binding [*out* f] + (show-doc pattern)))) |