I want to add JSDoc documentation for the property added as Object.defineProperty. I guess that something like this might work:
/** @constructor */                                                         
function MyClass() {                                                        
  /** @property {Number} rnd */                                             
  Object.defineProperty(this, 'rnd', {                                      
    get : function () { return Math.random(); }                             
  });                                                                       
}                                                                           
But the generated JSDoc explanation does not have this property:
$ jsdoc -X test.js
[
    {
        "comment": "/** @constructor */",
        "meta": {
            "range": [ 20, 167 ],
            "filename": "test.js",
            "lineno": 2,
            "path": "/jsdoctest",
            "code": {
                "id": "astnode100000001",
                "name": "MyClass",
                "type": "FunctionDeclaration",
                "paramnames": []
            },
            "vars": { "": null }
        },
        "kind": "class",
        "name": "MyClass",
        "longname": "MyClass",
        "scope": "global"
    },
    {
        "comment": "",
        "meta": {
            "range": [ 116, 159 ],
            "filename": "test.js",
            "lineno": 5,
            "path": "/jsdoctest",
            "code": {
                "id": "astnode100000012",
                "name": "get",
                "type": "FunctionExpression",
                "value": "function"
            }
        },
        "undocumented": true,
        "name": "get",
        "longname": "get",
        "kind": "function",
        "scope": "global"
    },
    {
        "kind": "package",
        "longname": "package:undefined",
        "files": [ "/jsdoctest/test.js" ]
    }
]
What will be the most appropriate approach to document this kind of properties? (Plugin maybe?)
                        
This would do it:
I've used the
@property {type} namesyntax but never inside of a class. What I typically do is something like:And then jsdoc uses
this.footo compute the name (foo) and which entity it belongs to. It appears that using@property {type} namein a class does not work.If you specify the name with
@name, then it knows what name to give to it and where it belongs. The#indicates that it is an instance variable (rather than static or inner). See the namepath documentation for details.