clojure

How to get doc string for a clojure interface?


Is it possible to get doc-string for a clojure interface or other syntactic entity?

(defn documentedFun "documentedFun is documented" [] 123)
(assert (= (:doc (meta #'documentedFun)) "documentedFun"))

An interface with doc attribute seems syntactically correct:

(definterface ^{:doc "Eq is an interface"} Eq (^{:tell bool} eq [b]) )

but REPL cannot parse doc function applied to Eq.

(doc Eq)

Syntax error compiling var at (/tmp/form-init4163264810453251954.clj:1:1). Expecting var, but Eq is mapped to interface hello_leiningen.core.Eq


Solution

  • No. Metadata lives on Clojure vars, and interfaces are purely a Java feature. There's nowhere to put the metadata. You could define a protocol instead: a protocol has a var, and defining a protocol also defines an interface.