@use JSDoc

概要

ドキュメント化された項目の使用方法の例を提示します。このタグに続くテキストはハイライトされたコードとして表示されます。

ドキュレットには複数の例がある可能性があることに注意してください。

例をドキュメント化
/**
 * Solves equations of the form a * x = b
 * @example
 * // returns 2
 * globalNS.method1(5, 10);
 * @example
 * // returns 3
 * globalNS.method(5, 15);
 * @returns {Number} Returns the value of x for the equation.
 */
globalNS.method1 = function (a, b) {
    return b / a;
};

例は、@example タグの後に <caption></caption> を使用してキャプションを付けることもできます。

例をキャプション付きでドキュメント化
/**
 * Solves equations of the form a * x = b
 * @example &lt;caption>Example usage of method1.&lt;/caption>
 * // returns 2
 * globalNS.method1(5, 10);
 * @returns {Number} Returns the value of x for the equation.
 */
globalNS.method1 = function (a, b) {
    return b / a;
};