Rush Stack商店博客活动
跳到主要内容

@inheritDoc

标准化扩展
语法种类内联标签

用法

此内联标签用于通过从另一个 API 项目复制文档来自动生成 API 项目的文档。内联标签参数包含对另一个项目的引用,该项目可能是不相关的类,甚至是从单独的 NPM 包导入的项目。

注意:声明引用的表示法尚未最终确定。请参阅 GitHub issue #9

复制的内容

@inheritDoc 标签不会复制整个注释主体。仅复制以下组件

  • 摘要部分
  • @remarks 区块
  • @params 区块
  • @typeParam 区块
  • @returns 区块

其他标签(例如 @defaultValue@example)不会被复制,需要显式地包含在 @inheritDoc 标签之后。当指定 @inheritDoc 标签时,注释中既不能指定摘要部分,也不能指定 @remarks 部分。

示例

import { Serializer } from 'example-library';

/**
* An interface describing a widget.
* @public
*/
export interface IWidget {
/**
* Draws the widget on the display surface.
* @param x - the X position of the widget
* @param y - the Y position of the widget
*/
public draw(x: number, y: number): void;
}

/** @public */
export class Button implements IWidget {
/** {@inheritDoc IWidget.draw} */
public draw(x: number, y: number): void {
. . .
}

/**
* {@inheritDoc example-library#Serializer.writeFile}
* @deprecated Use {@link example-library#Serializer.writeFile} instead.
*/
public save(): void {
. . .
}
}