ラッシュ スタックショップブログイベント
メインのコンテンツへスキップ

@example

タグの種類: ブロック タグ

TSDoc 標準化: 拡張

API の使用方法を示す例として提示する必要があるドキュメント セクションを示します。コード サンプルを含めることができます。

使用例

/**
* Adds two numbers together.
*
* @remarks
* Use this function to perform example addition.
*
* @example
* Here's a simple example:
* ```
* // Prints "2":
* console.log(add(1,1));
* ```
*
* @example
* Here's an example with negative numbers:
* ```
* // Prints "0":
* console.log(add(1,-1));
* ```
*
* @param x - the first number to add
* @param y - the second number to add
* @public
*/
export function add(x: number, y: number): number {
return x + y;
}

API ドキュメンターは、example セクションに自動的に番号を付けます。

出力は次のようになります

add() 関数

2 つの数字を足します。
export declare function add(x: number, y: number): number;
シグネチャ
パラメータパラメータタイプ
説明xnumber
加算する最初の数字xy
number

x

加算する 2 番目の数字

返り値

remarks

この関数を使用して、例の加算を実行します。

// Prints "2":
console.log(add(1,1));
例 1

負の値の例を次に示します

// Prints "0":
console.log(add(1,-1));

関連情報