(defexamples k & examples)
Defines multiple example code blocks for a symbol or an arbitrary
piece of Clojure data. If `k` is not a namespace-qualified symbol or
keyword, it will be associated with the current namespace.
Example
Define multiple examples of the `conj` function
(defexamples
clojure.core/conj
["Add a name to a vector" (conj ["Alice" "Bob"] "Charlie")]
["Add a number to a list" (conj '(2 3) 1)]
[{:doc "Add a key-val pair to a hash map",
:ret (fn [m] (= m {:name "Alice", :age 30}))}
(conj {:name "Alice"} [:age 30])])
Spec
(clojure.spec.alpha/fspec
:args
:dynadoc.example/examples
:ret
clojure.core/any?
:fn
nil)
Source
(defmacro defexamples
"Defines multiple example code blocks for a symbol or an arbitrary
piece of Clojure data. If `k` is not a namespace-qualified symbol or
keyword, it will be associated with the current namespace."
[k & examples]
(apply defexamples* k examples))