aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorBen Smith-Mannschott <bsmith.occs@gmail.com>2010-08-28 19:00:22 +0200
committerStuart Sierra <mail@stuartsierra.com>2010-09-03 12:23:37 -0400
commit67e85be147095c87a3cec82a64455974f29c7fd7 (patch)
tree546ef4949e3db2111b79f60e19d76d5e03722c3a /modules
parent9a05c1c70a1070f5a631dfc81ed98d6c70b33a9d (diff)
removed deprecated source, get-source, apropos from clojure.contrib.repl-utils.
available in clojure.repl as source, source-fn, and apropos, respectively. Signed-off-by: Stuart Sierra <mail@stuartsierra.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/gen-html-docs/pom.xml5
-rw-r--r--modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj5
-rw-r--r--modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj49
-rw-r--r--modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj20
4 files changed, 3 insertions, 76 deletions
diff --git a/modules/gen-html-docs/pom.xml b/modules/gen-html-docs/pom.xml
index 80cc2cd5..98895b6d 100644
--- a/modules/gen-html-docs/pom.xml
+++ b/modules/gen-html-docs/pom.xml
@@ -14,11 +14,6 @@
<dependencies>
<dependency>
<groupId>org.clojure.contrib</groupId>
- <artifactId>repl-utils</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.clojure.contrib</groupId>
<artifactId>prxml</artifactId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
diff --git a/modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj b/modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj
index 145c040b..e2ad61dd 100644
--- a/modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj
+++ b/modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj
@@ -47,7 +47,8 @@
one or more Clojure libraries."}
clojure.contrib.gen-html-docs
(:require [clojure.string :as s])
- (:use [clojure.contrib repl-utils def prxml])
+ (:use [clojure [repl :only [source-fn]]])
+ (:use [clojure.contrib def prxml])
(:import [java.lang Exception]
[java.util.regex Pattern]))
@@ -290,7 +291,7 @@ function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
(try
(let [docs (:doc (meta v))
src (if-let [ns (find-ns libid)]
- (get-source (symbol-for ns memberid)))]
+ (source-fn (symbol-for ns memberid)))]
(if (and src docs)
(doc-elided-src docs src)
src))
diff --git a/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj b/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj
index 39195ea0..e9bdb669 100644
--- a/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj
+++ b/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils.clj
@@ -116,55 +116,6 @@
(printf "[%2d] %s\n" i (:text m)))))))))
;; ----------------------------------------------------------------------
-;; Examine Clojure functions (Vars, really)
-
-(defn get-source
- "Returns a string of the source code for the given symbol, if it can
- find it. This requires that the symbol resolve to a Var defined in
- a namespace for which the .clj is in the classpath. Returns nil if
- it can't find the source. For most REPL usage, 'source' is more
- convenient.
-
- Example: (get-source 'filter)"
- {:deprecated "1.2"}
- [x]
- (when-let [v (resolve x)]
- (when-let [filepath (:file (meta v))]
- (when-let [strm (.getResourceAsStream (RT/baseLoader) filepath)]
- (with-open [rdr (LineNumberReader. (InputStreamReader. strm))]
- (dotimes [_ (dec (:line (meta v)))] (.readLine rdr))
- (let [text (StringBuilder.)
- pbr (proxy [PushbackReader] [rdr]
- (read [] (let [i (proxy-super read)]
- (.append text (char i))
- i)))]
- (read (PushbackReader. pbr))
- (str text)))))))
-
-(defmacro source
- "Prints the source code for the given symbol, if it can find it.
- This requires that the symbol resolve to a Var defined in a
- namespace for which the .clj is in the classpath.
-
- Example: (source filter)"
- {:deprecated "1.2"}
- [n]
- `(println (or (get-source '~n) (str "Source not found"))))
-
-(defn apropos
- "Given a regular expression or stringable thing, return a seq of
-all definitions in all currently-loaded namespaces that match the
-str-or-pattern."
- {:deprecated "1.2"}
- [str-or-pattern]
- (let [matches? (if (instance? java.util.regex.Pattern str-or-pattern)
- #(re-find str-or-pattern (str %))
- #(.contains (str %) (str str-or-pattern)))]
- (mapcat (fn [ns]
- (filter matches? (keys (ns-publics ns))))
- (all-ns))))
-
-;; ----------------------------------------------------------------------
;; Handle Ctrl-C keystrokes
(def ^{:doc "Threads to stop when Ctrl-C is pressed. See 'add-break-thread!'"}
diff --git a/modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj b/modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj
deleted file mode 100644
index 6fa12ed7..00000000
--- a/modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj
+++ /dev/null
@@ -1,20 +0,0 @@
-(ns clojure.contrib.test-repl-utils
- (:use clojure.test
- clojure.contrib.repl-utils))
-
-(deftest test-apropos
- (testing "with a regular expression"
- (is (= '[defmacro] (apropos #"^defmacro$")))
- (is (some '#{defmacro} (apropos #"def.acr.")))
- (is (= [] (apropos #"nothing-has-this-name"))))
-
-
- (testing "with a string"
- (is (some '#{defmacro} (apropos "defmacro")))
- (is (some '#{defmacro} (apropos "efmac")))
- (is (= [] (apropos "nothing-has-this-name"))))
-
- (testing "with a symbol"
- (is (some '#{defmacro} (apropos 'defmacro)))
- (is (some '#{defmacro} (apropos 'efmac)))
- (is (= [] (apropos 'nothing-has-this-name)))))