JsDoc:删除“;静态“;来自属性的标记

JsDoc: Remove "static" tag from property

本文关键字:属性 静态 删除 JsDoc      更新时间:2024-06-13

我有用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;
            }
        }
    });
    ....
}

基本上,我要做的是确保图形不能使用其他方法来操作,而不是通过提供节点列表的副本而不是实际的节点列表来提供的方法。

这很好,但在JsDoc中,它被定义为静态:

<static>    Graph.nodes
            An array of all node handles in the graph

现在,这个属性不是静态的。它对于图的所有实例都是单独的。我的猜测是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;
            }
        }
    });
}