Skip to content

Commit b52f0b6

Browse files
test-load-all tries to load all nondeprecated namespaces
- fixed bug: misspelling in pom - updated gen-html-docs to track c.c.string name changes
1 parent b9db280 commit b52f0b6

File tree

4 files changed

+60
-97
lines changed

4 files changed

+60
-97
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
<namespaces>
9494
<namespace>clojure\.contrib\.jmx\.Bean</namespace>
9595
<namespace>clojure\.contrib\.fnmap\.PersistentFnMap</namespace>
96-
<namespace>clojure\.contrib\.conditition\.Condition</namespace>
96+
<namespace>clojure\.contrib\.condition\.Condition</namespace>
9797
<namespace>clojure\.contrib\.repl-ln</namespace>
9898
<namespace>clojure\.contrib\.pprint\.gen-class</namespace>
9999
</namespaces>

src/main/clojure/clojure/contrib/gen_html_docs.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@
4646
:doc "Generates a single HTML page that contains the documentation for
4747
one or more Clojure libraries."}
4848
clojure.contrib.gen-html-docs
49-
(:require [clojure.contrib.io :as io])
50-
(:use [clojure.contrib seq string repl-utils def prxml])
49+
(:require [clojure.contrib.io :as io]
50+
[clojure.contrib.string :as s])
51+
(:use [clojure.contrib seq repl-utils def prxml])
5152
(:import [java.lang Exception]
5253
[java.util.regex Pattern]))
5354

@@ -226,7 +227,7 @@ function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
226227
(if (= 0 (count l))
227228
[:span {:class "library-member-doc-whitespace"} " "] ; We need something here to make the blank line show up
228229
l)])
229-
(re-split #"\n" docs))
230+
(s/split #"\n" docs))
230231
""))
231232

232233
(defn- member-type
@@ -270,7 +271,7 @@ function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
270271
(defn- elide-to-one-line
271272
"Elides a string down to one line."
272273
[s]
273-
(re-sub #"(\n.*)+" "..." s))
274+
(s/replace-re #"(\n.*)+" "..." s))
274275

275276
(defn- elide-string
276277
"Returns a string that is at most the first limit characters of s"
@@ -282,7 +283,7 @@ function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
282283
(defn- doc-elided-src
283284
"Returns the src with the docs elided."
284285
[docs src]
285-
(re-sub (re-pattern (str "\"" (Pattern/quote docs) "\""))
286+
(s/replace-re (re-pattern (str "\"" (Pattern/quote docs) "\""))
286287
(str "\""
287288
(elide-to-one-line docs)
288289
;; (elide-string docs 10)

src/main/clojure/clojure/contrib/load_all.clj

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
;;; test_load_all.clj - loads all contrib libraries for testing purposes
2+
3+
;; by Stuart Halloway, http://blog.thinkrelevance.com
4+
5+
;; Copyright (c) Stuart Halloway, 2009. All rights reserved. The use
6+
;; and distribution terms for this software are covered by the Eclipse
7+
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
8+
;; which can be found in the file epl-v10.html at the root of this
9+
;; distribution. By using this software in any fashion, you are
10+
;; agreeing to be bound by the terms of this license. You must not
11+
;; remove this notice, or any other, from this software.
12+
13+
;; This is only intended to check that the libraries will load without
14+
;; errors, not that they work correctly.
15+
16+
;; The code includes several design choices I don't love, but find
17+
;; tolerable in a test-only lib:
18+
;;
19+
;; * namespaces that blow up to document deprecation
20+
;; * using directory paths to find contrib
21+
;; * using a macro to reflectively write tests
22+
;;
23+
;; I *am* happy that code that won't even load now breaks the build.
24+
25+
(ns clojure.contrib.test-load-all
26+
(:use clojure.test clojure.contrib.find-namespaces))
27+
28+
(def deprecated-contrib-namespaces
29+
'[clojure.contrib.javadoc])
30+
31+
(defn loadable-contrib-namespaces
32+
"Contrib namespaces that can be loaded (everything except
33+
deprecated nses that throw on load.)"
34+
[]
35+
(apply disj
36+
(into #{} (find-namespaces-in-dir (java.io.File. "src/main")))
37+
deprecated-contrib-namespaces))
38+
39+
(defn emit-test-load
40+
[]
41+
`(do
42+
~@(map
43+
(fn [ns]
44+
`(deftest ~(symbol (str "test-loading-" (.replace (str ns) "." "-")))
45+
(require :reload '~ns)))
46+
(loadable-contrib-namespaces))))
47+
48+
(defmacro test-load
49+
[]
50+
(emit-test-load))
51+
52+
(test-load)
53+

0 commit comments

Comments
 (0)