@inherits¶
-
.. @inheritdoc::
¶ - 语法
@inheritdoc
- 概述
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.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.
The presence of the
@inheritdoc
tag implies the presence of the@override
.- 示例
以下示例显示了类如何指示它从其父类继承文档:
Class that inherits from a 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注释来获得相同的结果:
Inheriting documentation without the@inheritdoc
tag¶/** * @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() { // ... };