(defexample k & args)

Defines one example code block 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 an example of a function in another namespace
(defexample clojure.core/+ "Add two numbers together" (+ 1 1))
Define an example of a function in the current namespace
(defexample parse-ns "Get the namespace from a symbol" (parse-ns 'my.namespace/asdf))
Define an example of a function with an assertion for testing
(defexample parse-ns {:doc "Get the namespace from a symbol", :ret (fn [n] (= n 'my.namespace))} (parse-ns 'my.namespace/asdf))

Spec

(clojure.spec.alpha/fspec :args :dynadoc.example/example :ret clojure.core/any? :fn nil)

Source

(defmacro defexample "Defines one example code block 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 & args] (apply defexample* k args))