Re: [gabriel.reid@gmail.com: Re: [Jsdoc-user] fix for objects that are extended with this.base membe
Status: Inactive
Brought to you by:
mmathews
From: Gabriel R. <gab...@gm...> - 2005-09-02 19:46:57
|
Hi Justin, > I understand your point, maybe the base member name can be a optional > parameter such as --basemembernames base,baseObj. This idiom is extremely > useful especially when it is part of the coding standard. I found that when > I ran our JS docs with this param I found that the tree was formed rather > than requiring manual @extends keys from being added. What do you think? I think that there is actually a miscommunication here. Just assigning a base class constructor function to a property inside of another constructor function, like this: function BaseClass(pName){ this.name = pName; } function SubClass(){ this.base = BaseClass; this.base("someName"); } does not necessarily set up any kind of inheritance relationship between the two classes. The inheritance relationship *is* set up when you assign an instance of the base class to the subclass' prototype, as follows: SubClass.prototype = new BaseClass(); When you use the above construction, JSDoc correctly picks up the inheritance relationship without the need for the @extends tag (or at least, it should pick it up!). To top all of this off, I'm also looking at making the parser somewhat "smarter" so that it can handle additions to the Function prototype (as all "classes" are actually based on the Function class), which would clear up any kind of problem such as the one we're discussing here. However, that won't be coming anytime terribly soon, I'm afraid. Regards, Gabriel > > On 9/1/05, Gabriel Reid <gab...@gm...> wrote: > > > > On Thu, Sep 01, 2005 at 05:54:30PM -0700, Justin Early wrote: > > > Hi Gabriel, > > > Here is the example of a where you can use this: > > > function MyBaseClass(pName) > > > { > > > this.name <http://this.name> <http://this.name> = pName; > > > this.prop1 = "test"; > > > } > > > function MyExtendedBaseClass(pName) > > > { > > > //set Base class > > > this.base = MyBaseClass; > > > this.base(pName); > > > } > > > Examples are here: > > > > > http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:The_Employee_Example:More_Flexible_Constructors > > > > I'm not really in favour of adding this to the code of JSDoc, as the > > 'base' object isn't actually part of JavaScript or ECMAScript. Although > > it's certainly a useful idiom, the 'base' object could just as easily be > > called any other name and have the same effect. > > > > Additionally, in the example in the link that you provided, a > > constructor is assigned to the prototype of a subclass, which JSDoc will > > pick up and represent as subclassing. > > > > Regards, > > > > Gabriel > > > > > > -- > It's a cool add-in for Outlook that automatically organizes your email. I > think it's great! > > ________________________________ > Click http://www.caelo.com/a/rl.php3?i=U30ZD to check it out. |