[英]How to document an event handler in JSDoc?
Suppose I have a class like this:假设我有一个这样的类:
function myClass(q) {
this.someFunction = function(e) {
console.log("Click event");
};
jQuery(q).click(this.someFunction);
}
Is there a way to indicate to JSDoc that someFunction is not just a function that should be invoked directly but rather is an event handler ?有没有办法向 JSDoc 表明 someFunction 不仅仅是一个应该直接调用的函数,而是一个事件处理程序?
I see the @event tag but if I understand correctly this is more to document a function in my class that I consider to be an event (something the client code would register too and that my class will fire when needed) and not an event handler function ?我看到了 @event 标签,但如果我理解正确,这更多是为了记录我认为是事件的类中的函数(客户端代码也会注册并且我的类将在需要时触发)而不是事件处理程序功能 ?
No, there is no way to document an event handler.
不,没有办法记录事件处理程序。
So the best way is to document it as a normal function maybe writing in its description in bold text or upper case that is an "EVENT HANDLER".
所以最好的方法是将它记录为一个正常的函数,也许在它的描述中用粗体或大写写成“事件处理程序”。
You probably already now this, but just in case: you can write it in bold by simply wrapping the text into html tags
<strong></strong>
.
您现在可能已经这样做了,但以防万一:您可以通过简单地将文本包装到 html 标签
<strong></strong>
以粗体编写它。
This answer is now deprecated but it does not let me delete it.这个答案现在已被弃用,但它不允许我删除它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.