jsdoc / jsdoc

An API documentation generator for JavaScript.
https://jsdoc.app/
Apache License 2.0
15.01k stars 1.44k forks source link

@inheritdoc fails in situation with 2 classes and 2 interfaces #912

Open myphysicslab opened 9 years ago

myphysicslab commented 9 years ago

The situation is: class D extends class C which implements interface B which extends interface A. The documentation for the method defined on interface A appears in docs for A, B, C, but not in D. (The method appears but without return type or description).

In the following example: SampleSubject extends AbstractSubject which implements Subject interface which extends Printable interface. The problem is the toStringShort method in SampleSubject is lacking documentation. The resulting documentation can be seen at: http://www.myphysicslab.com/rmnp/test20150206/out/index.html Below is the code for this example. Also available at http://www.myphysicslab.com/rmnp/test20150206/test20150206.js Using JSDoc 3.4.0-dev (Thu, 22 Jan 2015 23:02:06 GMT)

/** @classdesc An object that has a minimal string representation via
the `toStringShort` method.
* @interface
*/
myphysicslab.lab.util.Printable = function() {};

/** Returns a minimal string representation of this object, usually
giving just identity information like the class name and name of the
object.
@method
@return {string} a minimal string representation of this object.
*/
myphysicslab.lab.util.Printable.prototype.toStringShort;

/** @classdesc A {Subject} notifies its {Observer}s when something changes in the
{Subject}.
@interface
* @extends {myphysicslab.lab.util.Printable}
*/
myphysicslab.lab.util.Subject = function() {};

/** Returns the JavaScript symbol that refers to this {Subject} for usage in a Terminal
script.
@method
@return {string} the symbol of this {Subject}.
*/
myphysicslab.lab.util.Subject.prototype.getSymbol;

/** @classdesc A *reusable forwarding class* which implements the boilerplate code
for a {Subject}.
@constructor
@implements {myphysicslab.lab.util.Subject}
*/
myphysicslab.lab.util.AbstractSubject = function() {};

/** @inheritDoc */
myphysicslab.lab.util.AbstractSubject.prototype.getSymbol = function() {
  return "foo";
};

/** @inheritDoc */
myphysicslab.lab.util.AbstractSubject.prototype.toStringShort = function() {
  return "AbstractSubject";
};

/** @classdesc A class that extends AbstractSubject.
* @constructor
* @extends {myphysicslab.lab.util.AbstractSubject}
*/
myphysicslab.lab.model.SampleSubject = function() {};

/** @inheritDoc */
myphysicslab.lab.model.SampleSubject.prototype.getSymbol = function() {
  return "bar";
};

/** @inheritDoc */
myphysicslab.lab.model.SampleSubject.prototype.toStringShort = function() {
  return "SampleSubject";
};
hegemonic commented 9 years ago

@myphysicslab You have done an excellent job of stress-testing JSDoc's inheritance-related code. :)

I'll see whether another Band-Aid and a fresh piece of chewing gum can keep this thing flying.

hegemonic commented 9 years ago

I don't see a clean way to hack around this bug for JSDoc 3.3.0. Furthermore, the code in jsdoc/augment has already turned into a real mess. I think I'll need to rewrite a large portion of the code for JSDoc 3.4.0, with an eye towards fixing this bug and preventing similar bugs.