[英]Inheriting documentation in JSDoc
我正在嘗試為我的 JS 項目編寫文檔,並且我的代碼是面向對象的。 這是一個示例代碼:
/**
* @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;
我有兩個問題:
@property...
行,我如何才能做到這一點?@inheritdoc \ @override
但它不起作用。 你有什么想法?我使用以下方法解決了我的問題:
/**
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;
所以基本上是為了:
this
代替self
)。param
和returns
行並刪除 rest,從self
更改為this
使其直接工作。 它會自行檢測覆蓋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.