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.
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;
}
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With