javascript - JsDoc: Remove "static" tag from property - Stack Overflow

I have graph constructor written in JavaScript. The documentation is a bit borked. Below is the part of

I have graph constructor written in JavaScript. The documentation is a bit borked. Below is the part of my code and the documentation which does not work as I want:

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

Basically, what I'm trying to do is to make sure the graph can't be manipulated using other means than the methods provided by giving a copy of the node list, not the actual node list.

This works well, but in the JsDoc, it is defined as static:

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

Now, this property is not static. It is individual for all instances of graphs. My guess is that JsDoc recognizes the definition of the nodes property to be inside Object.defineProperties(), and claims that all declarations inside here are static.

Is there a way to tell JsDoc that this property is in fact not static? I could only find the tag @static, which does the exact opposite.

I have graph constructor written in JavaScript. The documentation is a bit borked. Below is the part of my code and the documentation which does not work as I want:

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

Basically, what I'm trying to do is to make sure the graph can't be manipulated using other means than the methods provided by giving a copy of the node list, not the actual node list.

This works well, but in the JsDoc, it is defined as static:

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

Now, this property is not static. It is individual for all instances of graphs. My guess is that JsDoc recognizes the definition of the nodes property to be inside Object.defineProperties(), and claims that all declarations inside here are static.

Is there a way to tell JsDoc that this property is in fact not static? I could only find the tag @static, which does the exact opposite.

Share Improve this question edited Feb 28, 2015 at 15:20 Suppen asked Feb 27, 2015 at 11:45 SuppenSuppen 8561 gold badge7 silver badges21 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 9

There is @instance, see the documentation

// Edit: Working example

/**
 * @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;
            }
        }
    });
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744359469a4570398.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信