macro | since v0.0-2985 | clojure.repl/find-doc | Edit |
(find-doc re-string-or-pattern)
Prints documentation for any var whose documentation or name
contains a match for re-string-or-pattern
.
(find-doc "some")
;; Prints: (docs truncated)
;; - IPrintWriter (docstring match)
;; - contains? (docstring match)
;; - gensym (docstring match)
;; - cljs.core/if-some
;; - some
;; - cljs.core/some->
;; - cljs.core/some->>
;; - some-fn
;; - some?
;; - trampoline (docstring match)
;; - cljs.core/when-some
;; - cljs.core/while (docstring match)
;;
;;=> nil
Prints documentation for any var whose documentation or name contains a match for re-string-or-pattern
(defmacro find-doc
[re-string-or-pattern]
(let [re (re-pattern re-string-or-pattern)
ms (concat
(mapcat
(fn [ns]
(map
(fn [m]
(update-in (select-keys m [:ns :name :doc :forms :arglists :macro :url])
[:name] #(if-not (nil? %) (clojure.core/name %) %)))
(sort-by :name (vals (ana-api/ns-interns ns)))))
(ana-api/all-ns))
(map #(select-keys (ana-api/find-ns %) [:name :doc]) (ana-api/all-ns))
(map special-doc (keys special-doc-map)))
ms (for [m ms
:when (and (:doc m)
(or (re-find (re-matcher re (:doc m)))
(re-find (re-matcher re (str (:name m))))))]
m)]
`(doseq [m# (quote ~ms)]
(cljs.repl/print-doc m#))))