Skip to content

Commit b369fe1

Browse files
committed
CLJS-2725: Doc on spec keywords
1 parent 8614498 commit b369fe1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main/cljs/cljs/repl.cljs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
(defn print-doc [{n :ns nm :name :as m}]
1414
(println "-------------------------")
15-
(println (str (when-let [ns (:ns m)] (str ns "/")) (:name m)))
15+
(println (or (:spec m) (str (when-let [ns (:ns m)] (str ns "/")) (:name m))))
1616
(when (:protocol m)
1717
(println "Protocol"))
1818
(cond
@@ -38,6 +38,8 @@
3838
(do
3939
(when (:macro m)
4040
(println "Macro"))
41+
(when (:spec m)
42+
(println "Spec"))
4143
(when (:repl-special-function m)
4244
(println "REPL Special Function"))
4345
(println " " (:doc m))

src/main/clojure/cljs/repl.cljc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,8 @@ itself (not its value) is returned. The reader macro #'x expands to (var x)."}})
12311231
:repl-special-function true))
12321232

12331233
(defmacro doc
1234-
"Prints documentation for a var or special form given its name"
1234+
"Prints documentation for a var or special form given its name,
1235+
or for a spec if given a keyword"
12351236
[name]
12361237
`(print
12371238
(binding [cljs.core/*print-newline* true]
@@ -1245,6 +1246,9 @@ itself (not its value) is returned. The reader macro #'x expands to (var x)."}})
12451246
(repl-special-doc-map name)
12461247
`(cljs.repl/print-doc (quote ~(repl-special-doc name)))
12471248

1249+
(keyword? name)
1250+
`(cljs.repl/print-doc {:spec ~name :doc (cljs.spec.alpha/describe ~name)})
1251+
12481252
(ana-api/find-ns name)
12491253
`(cljs.repl/print-doc
12501254
(quote ~(select-keys (ana-api/find-ns name) [:name :doc])))

0 commit comments

Comments
 (0)