[英]Documenting a Backbone constructor with JSDoc?
我有一个基本视图方法,我的应用程序有一个close方法。 它工作得很好,直到我必须记录它; 基本上我正在进行一个不必要的函数调用,以便正确记录它。 由于Backbone已经有了一个初始化函数,所以在这里再次调用它是没有意义的,占用代码行..但如果我从代码中删除此函数,则不会生成视图的文档。 我的代码看起来像这样:
/**
* @exports BaseView
*/
define(['backbone'], function( Backbone ) {
'use strict';
return Backbone.View.extend( /** @lends BaseView.prototype */ {
/**
* Base view with close method
* @exports BaseView
* @augments Backbone.View
* @constructor
*/
initialize: function() {
Backbone.View.prototype.initialize.call(this);
},
/**
* Removes the view from the DOM and unbinds all events.
*/
close: function() {
this.remove();
this.unbind();
if (this.onClose) {
// Optionally, run additional cleanup methods.
this.onClose();
}
}
});
});
这个问题让我在正确的轨道上进行了记录,但是现在我想知道在JSDoc中是否可以记录initialize方法是从Backbone.View继承而不是编写函数调用。
如果有人能指出我正确的方向,将不胜感激。 谢谢。
以下是否符合您的要求? 我刚刚删除了initialize
函数,将@name BaseView
添加到它前面的doclet并删除了同一doclet中的@exports ...
因为它似乎不正确。
/**
* @exports BaseView
*/
define(['backbone'], function( Backbone ) {
'use strict';
return Backbone.View.extend( /** @lends BaseView.prototype */ {
/**
* Base view with close method
* @augments Backbone.View
* @constructor
* @name BaseView
*/
/**
* Removes the view from the DOM and unbinds all events.
*/
close: function() {
this.remove();
this.unbind();
if (this.onClose) {
// Optionally, run additional cleanup methods.
this.onClose();
}
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.