構文
@implements {型式表現}
概要
@implements
タグは、シンボルがインターフェイスを実装することを示しています。
@implements
タグを実装するトップレベルのシンボル (たとえば、コンストラクター関数) に追加します。実装のメンバーそれぞれ (たとえば、実装のインスタンスメソッド) に @implements
タグを追加する必要はありません。
実装内のシンボルのいずれかをドキュメント化しない場合、JSDoc はそのシンボルに対して自動的にインターフェイスのドキュメントを使用します。
例
次の例では、TransparentColor
クラスは Color
インターフェイスを実装し、TransparentColor#rgba
メソッドを追加します。
/**
* Interface for classes that represent a color.
*
* @interface
*/
function Color() {}
/**
* Get the color as an array of red, green, and blue values, represented as
* decimal numbers between 0 and 1.
*
* @returns {Array<number>} An array containing the red, green, and blue values,
* in that order.
*/
Color.prototype.rgb = function() {
throw new Error('not implemented');
};
/**
* Class representing a color with transparency information.
*
* @class
* @implements {Color}
*/
function TransparentColor() {}
// inherits the documentation from `Color#rgb`
TransparentColor.prototype.rgb = function() {
// ...
};
/**
* Get the color as an array of red, green, blue, and alpha values, represented
* as decimal numbers between 0 and 1.
*
* @returns {Array<number>} An array containing the red, green, blue, and alpha
* values, in that order.
*/
TransparentColor.prototype.rgba = function() {
// ...
};