[英]How to jsdoc annotate BackboneJS code?
有没有人用JSDoc记录BackboneJS代码?
我在注释Backbone构造时遇到问题,例如:
User = Backbone.Model.extend({
defaults: { a: 1 },
initialize: function () {
// ...
},
doSomething: function (p) {
// ...
}
});
任何建议表示赞赏 谢谢。
如果您在谈论JSDoc工具包,我认为它在某种程度上是这样的:
User = Backbone.Model.extend(
/** @lends User.prototype */
{
/**
* @class User class description
*
* @augments Backbone.Model
* @constructs
*
* Text for the initialize method
*/
initialize: function() {}
})
重要的一点是@lends
标签的位置!
这可能有点棘手,但如果这不起作用,请尝试其他一些示例: http : //code.google.com/p/jsdoc-toolkit/wiki/CookBook
chris_b的回答对我有很大帮助,样本以及链接。 不过,我不得不删除@class
注释,否则会为该类生成两个条目。 此外,我正在添加这个答案,以展示如何注释静态类成员(类级别常量)。
(我们使用require.js。)
define([
'jquery', 'lodash', 'backbone'
], function($, _, Backbone) {
"use strict";
/**
* Enumeration of constants that represent the different types of Hedgehogs.
* @memberof models/Hedgehog
* @enum {string}
* @readonly
*/
var types = { 'type1': 'Type 1', 'type2': 'Type 2' };
var Hedgehog = Backbone.Model.extend(
/** @lends models/Hedgehog.prototype */
{
/**
* This is the model for Hedgehogs.
*
* @augments external:Backbone.Model
* @constructs
*/
initialize: function() {
// your code
},
// some more methods
}, {
// static class members
"types": types
});
return Hedgehog;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.