我有用JavaScript编写的图形构造函数.文档有点笨拙.下面是我的代码部分和文档,它不能按我的意愿工作:
function Graph() {
....
var nodes = [];
Object.defineProperties(this, {
/**
* An array of all node handles in the graph
*
* @return {Array}
*/
nodes: {
get: function() {
var ids = [];
for (var id in nodes) {
ids.push(id);
}
return ids;
}
}
});
....
}
Run Code Online (Sandbox Code Playgroud)
基本上,我要做的是确保使用除提供节点列表副本而不是实际节点列表提供的方法之外的其他方法来操作图形.
这很好用,但在JsDoc中,它被定义为static:
<static> Graph.nodes
An array of all node handles in the graph
Run Code Online (Sandbox Code Playgroud)
现在,这个属性不是静态的.它适用于所有图形实例.我的猜测是JsDoc识别出属于该nodes属性的定义Object.defineProperties(),并声称这里的所有声明都是静态的.
有没有办法告诉JsDoc这个属性实际上不是静态的?我只能找到@static完全相反的标签.
有@instance,请参阅文档
//编辑:工作示例
/**
* @constructor
*/
function Graph() {
var nodes = [];
Object.defineProperties(this, {
/**
* An array of all node handles in the graph
* @return {Array}
* @memberof Graph
* @instance
*/
nodes: {
get: function() {
var ids = [];
for (var id in nodes) {
ids.push(id);
}
return ids;
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1526 次 |
| 最近记录: |