JSDoc 中文网

概述

🌐 Overview

@inheritdoc 标签表示一个符号应从其父类继承文档。你在 JSDoc 注释中包含的任何其他标签将被忽略。

🌐 The @inheritdoc tag indicates that a symbol should inherit its documentation from its parent class. Any other tags that you include in the JSDoc comment will be ignored.

此标签用于与 闭包编译器 的兼容性。默认情况下,如果你未为符号添加 JSDoc 注释,该符号将继承其父级的文档。

🌐 This tag is provided for compatibility with Closure Compiler. By default, if you do not add a JSDoc comment to a symbol, the symbol will inherit documentation from its parent.

@inheritdoc 标签的存在意味着 @override 标签 的存在。

🌐 The presence of the @inheritdoc tag implies the presence of the @override tag.

示例

🌐 Examples

以下示例展示了一个类如何表明它继承自父类的文档:

🌐 The following example shows how a class can indicate that it inherits documentation from its parent class:

继承自父类的类
/**
 * @classdesc Abstract class representing a network connection.
 * @class
 */
function Connection() {}

/**
 * Open the connection.
 */
Connection.prototype.open = function() {
    // ...
};


/**
 * @classdesc Class representing a socket connection.
 * @class
 * @augments Connection
 */
function Socket() {}

/** @inheritdoc */
Socket.prototype.open = function() {
    // ...
};

你可以通过省略 Socket#open 上的 JSDoc 注释得到相同的结果:

🌐 You can get the same result by omitting the JSDoc comment from Socket#open:

继承没有 `@inheritdoc` 标签的文档
/**
 * @classdesc Abstract class representing a network connection.
 * @class
 */
function Connection() {}

/**
 * Open the connection.
 */
Connection.prototype.open = function() {
    // ...
};


/**
 * @classdesc Class representing a socket connection.
 * @class
 * @augments Connection
 */
function Socket() {}

Socket.prototype.open = function() {
    // ...
};