Skip to content

Commit d35f871

Browse files
committed
REPL support for spec
1 parent a28b4ef commit d35f871

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/cljs/cljs/repl.cljs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
;; You must not remove this notice, or any other, from this software.
88

99
(ns cljs.repl
10-
(:require-macros cljs.repl))
10+
(:require-macros cljs.repl)
11+
(:require [cljs.spec :as spec]))
1112

12-
(defn print-doc [m]
13+
(defn print-doc [{n :ns nm :name :as m}]
1314
(println "-------------------------")
1415
(println (str (when-let [ns (:ns m)] (str ns "/")) (:name m)))
1516
(when (:protocol m)
@@ -46,4 +47,11 @@
4647
(println " " name)
4748
(println " " arglists)
4849
(when doc
49-
(println " " doc)))))))
50+
(println " " doc))))
51+
(when n
52+
(when-let [specs (spec/fn-specs (symbol (str (ns-name n)) (name nm)))]
53+
(println "Spec")
54+
(run! (fn [[role spec]]
55+
(when (and spec (not (= spec ::spec/unknown)))
56+
(println " " (str (name role) ":") (spec/describe spec))))
57+
specs))))))

0 commit comments

Comments
 (0)