如何为协议中的单个函数编写 clojure 文档?
How to write clojure documentation for a single function in a protocol?
假设我有这样的协议:
(defprotocol X
(y [this z]))
如何编写仅针对函数 y
的文档?
执行此操作的正常方法是:
(defn y
"Some documentation"
[])
但如果我这样做:
(defprotocol X
(y
"Some documentation"
[this z]))
我得到以下异常:
java.lang.IllegalArgumentException: Parameter declaration missing
那么如何添加这种文档呢?
(defprotocol X
(y [this z] "Some documentation"))
您可以在 clojuredocs 上找到协议示例:
(defprotocol Fly
"A simple protocol for flying"
(fly [this] "Method to fly"))
或者点击你的 REPL 或查看 source :
;method signatures
(bar [this a b] \"bar docs\")
(baz [this a] [this a b] [this a b c] \"baz docs\"))
假设我有这样的协议:
(defprotocol X
(y [this z]))
如何编写仅针对函数 y
的文档?
执行此操作的正常方法是:
(defn y
"Some documentation"
[])
但如果我这样做:
(defprotocol X
(y
"Some documentation"
[this z]))
我得到以下异常:
java.lang.IllegalArgumentException: Parameter declaration missing
那么如何添加这种文档呢?
(defprotocol X
(y [this z] "Some documentation"))
您可以在 clojuredocs 上找到协议示例:
(defprotocol Fly
"A simple protocol for flying"
(fly [this] "Method to fly"))
或者点击你的 REPL 或查看 source :
;method signatures
(bar [this a b] \"bar docs\") (baz [this a] [this a b] [this a b c] \"baz docs\"))