JSDoc 中文网

语法

¥Syntax

@implements {typeExpression}

概述

¥Overview

@implements 标签表示符号实现了接口。

¥The @implements tag indicates that a symbol implements an interface.

@implements 标记添加到实现接口(例如构造函数)的顶层符号中。你不需要将 @implements 标记添加到实现的每个成员(例如,实现的实例方法)。

¥Add the @implements tag to the top-level symbol that implements the interface (for example, a constructor function). You do not need to add the @implements tag to each member of the implementation (for example, the implementation's instance methods).

如果你没有在实现中记录其中一个符号,JSDoc 将自动使用该符号的接口文档。

¥If you do not document one of the symbols in the implementation, JSDoc will automatically use the interface's documentation for that symbol.

示例

¥Examples

在以下示例中,TransparentColor 类实现 Color 接口并添加 TransparentColor#rgba 方法。

¥In the following example, the TransparentColor class implements the Color interface and adds a TransparentColor#rgba method.

使用@implements 标签
/**

 * 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() {
    // ...
};