I am trying to document my code using JSDoc but I can't figure out how to make it work for it to recognise class inheritance. Here is a sample code:
/**
* @classdesc Represents a Layer.
* @class
* @param {object} satellite - The satellite object.
* @param {string} date - The image date.
*
* @property {Satellite} satellite - The associated satellite.
*
*/
function Layer(satellite, date){
var self = this;
self.satellite = satellite;
/**
* Compute the water index from RGB imagery.
* @function compute_wi
* @memberOf Layer
* @param {ee.ImageCollection} rgb - RGB imagery.
*/
self.compute_wi = function(rgb){
var image = rgb.median();
return image.normalizedDifference(self.satellite.ndwi_bands);
};
}
/**
* @classdesc Class representing a Layer for SAR satellites.
* @class
* @augments Layer
*/
function SarLayer(satellite, date, img_layernumber, pre_post){
Layer.call(this, satellite, date, img_layernumber, pre_post);
var self = this;
/**
* Do nothing (not used for SAR imagery).
* @function compute_wi
* @memberOf SarLayer
* @override
* @param {ee.ImageCollection} rgb - RGB imagery.
* @returns {ee.ImageCollection} RGB imagery
*/
self.compute_wi = function(rgb){
return rgb;
};
}
SarLayer.prototype = Object.create(Layer.prototype);
SarLayer.prototype.constructor = SarLayer;
In the created JSDoc, I don't see that compute_wi in SARLayer is an overriden function from Layer. I see the attribute Satellite in the documentation of Layer but not in the one of SARLayer, how can I make it appear there? Same for the other methods that I don't override..
Here is an example of what I expected: expected
Here is what I get: actual
Is it because I declare my methods with the keyword self? Which I need to make class inheritance work (call superclass method when needed).
CodePudding user response:
You seem to lack the @instance
type hint that tells the JSDoc these are instance (not static) methods.
Applying the @instance
to both methods seem to yield the correct output of the documentation generator - I see an Overrides together with a link to the base class method (which is what you ask about).