Override methods

161 views
Skip to first unread message

Michał Przybysz

unread,
Aug 9, 2012, 10:17:39 AM8/9/12
to jsdoc...@googlegroups.com
Hi,

I have something like this:

/**
 * Description
 * * @constructor
 **/
alib.b.A = function() {};

/**
 * Description
 * @class
 * @extends alib.b.B
 **/
alib.b.B = alib.extend(alib.b.A, 
    /** @lends alib.b.B.prototype */
    {
   fade: function (config) {
       //do something
   },
//blabla
 });
/**
 * Description
 * @class
 * @extends alib.b.B
 **/
alib.b.C = alib.extend(alib.b.B, 
    /** @lends alib.b.C.prototype */
    {
   fade: function (config) {
       //do something
   },
   //blabla
});


It is proper way to document this code?? In output documentation method fade occurs twice.

Michael Mathews

unread,
Aug 10, 2012, 4:13:51 AM8/10/12
to Michał Przybysz, jsdoc...@googlegroups.com
Hello Michał,

I believe this is a bug, or at least I would consider it one: extended members with the same name should be overridden in the docs, not duplicated, in my opinion.

Here's a greatly simplified example case:

````javascript
/** @class */
A = function() {};
/** document me */
A.prototype.f = function() {
}

/** @class
    @extends A
*/
B = function() {};
/** document me */
B.prototype.f = function() {
}
````

I suspect this issue arises from the action of the [augments.js  file](https://github.com/jsdoc3/jsdoc/blob/master/rhino_modules/jsdoc/augment.js#L6).


@tschaub can you offer any further advice?

Michael Mathews
mic...@gmail.com



--
You received this message because you are subscribed to the Google Groups "JSDoc Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/jsdoc-users/-/ooZsGM5Cw1cJ.
To post to this group, send email to jsdoc...@googlegroups.com.
To unsubscribe from this group, send email to jsdoc-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jsdoc-users?hl=en.

Tim Schaub

unread,
Aug 10, 2012, 3:24:00 PM8/10/12
to jsdoc...@googlegroups.com
Is there any justification for there to be an array of doclets for a given name?

In augments.js, I followed the structure I saw being created here:

https://github.com/jsdoc3/jsdoc/blob/master/jsdoc.js#L155-160

I'll try to get that fixed up in the next couple hours. Might be that
when I get my head back into it I see the reason for the array.

https://github.com/jsdoc3/jsdoc/issues/158

Tim

Michael Mathews

unread,
Aug 10, 2012, 4:17:35 PM8/10/12
to tim.s...@gmail.com, jsdoc...@googlegroups.com
The array is to support _overloaded_ methods. But in the case of `@extends` and subclasses the assumption should be that the subclass always wants to override and not overload.

For example, given the following code, the "name" method should appear in the docs twice.

```javascript
/** @constructor */
function Person() {
}

/**
Set the name.
@param {string} n - The name to set.
*//**
Get the name
@returns {string} The name.
*/
Person.prototype.name = function(n) {
if (n) this.n = n;
else return n;
}
```

In addition it is possible to use the `@also` tag to document this sort of thing.

Michael Mathews
mic...@gmail.com
Reply all
Reply to author
Forward
0 new messages