I am trying to write documentation for my JS project, and my code is object-oriented. 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
* @instance
* @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
* @instance
* @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;
I have two issues:
@property...
line?@inheritdoc \ @override
but it doesn't work. Do you have any ideas?I solved my problem using:
/**
1. @classdesc Represents a Layer.
2. @class
3. @param {object} satellite - The satellite object.
4. @param {string} date - The image date.
5.
*/
function Layer(satellite, date){
var self = this;
/** Satellite object */
this.satellite = satellite;
/**
* Compute the water index from RGB imagery.
* @param {ee.ImageCollection} rgb - RGB imagery.
*/
this.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). */
this.compute_wi = function(rgb){
return rgb;
};
}
SarLayer.prototype = Object.create(Layer.prototype);
SarLayer.prototype.constructor = SarLayer;
So basically for:
this
instead of self
).param
and returns
lines and remove the rest, changing from self
to this
made it work directly. It will detect overriding by itself.