macro | since v0.0-2985 | ![]() | Edit |
(apropos str-or-pattern)
Given a regular expression or stringable thing, return a seq of all
public definitions in all currently-loaded namespaces that match the
str-or-pattern
.
(apropos "some")
;;=> (cljs.core/if-some
;; cljs.core/some
;; cljs.core/some->
;; cljs.core/some->>
;; cljs.core/some-fn
;; cljs.core/some?
;; cljs.core/when-some)
Given a regular expression or stringable thing, return a seq of all public definitions in all currently-loaded namespaces that match the str-or-pattern.
(defmacro apropos
[str-or-pattern]
(let [matches? (if (instance? Pattern str-or-pattern)
#(re-find str-or-pattern (str %))
#(.contains (str %) (str str-or-pattern)))]
`(quote
~(sort
(mapcat
(fn [ns]
(let [ns-name (str ns)]
(map #(symbol ns-name (str %))
(filter matches? (named-publics-vars ns)))))
(ana-api/all-ns))))))