mryozo16 / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

Feature Request: Parse JsDoc comments /** */ for __defineGetter__ and __defineSetter__ #223

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I frequently make "classes" in JavaScript, and I've found the best way (for
me) to define properties is via __defineGetter__ and __defineSetter__. Yes,
this is a Mozilla-based-JS only extension, but quite a few people use this
variant.

What I currently do is this:

function A() {

    var someObj = { foo: 3 };

    /**
     * JsDoc tags here
     */
    this.prop = null;
    this.__defineGetter__("prop", function() { return someObj.foo; });
}

While this works, it seems a bit redundant to have to define a property no
code sees, given the "getter" overwrites it. It just clutters the code, and
it would be better if I could document the getter directly.

Now, given that JS has both __defineGetter__ and __defineSetter__, if both
are tagged, the second one to be parsed would generate a warning stating it
overrides the first one, or something. (the reason to scan both is because
some properties only define one or the other).

What version of the product are you using? On what operating system?
2.2.1, Windows XP

I'd write a patch, but Walker.js makes my head explode. I think it is
possible given the current code as there seems to be a case for a function
call in there and that's exactly what __define[GS]etter__ is. However the
property name would have to be parsed out, and that doesn't seem like fun.

Original issue reported on code.google.com by mcbain....@gmail.com on 22 Jun 2009 at 2:08

GoogleCodeExporter commented 8 years ago

Original comment by micmath on 22 Jun 2009 at 8:38

GoogleCodeExporter commented 8 years ago

Original comment by micmath on 26 Jul 2009 at 11:02