JSDoc 中文网

语法

🌐 Syntax

@name <namePath>

概述

🌐 Overview

@name 标签强制 JSDoc 将 JSDoc 注释的其余部分与给定的名称关联,忽略所有周围的代码。该标签最适用于“虚拟注释”,用于那些在代码中不易看到的符号,例如在运行时生成的方法。

🌐 The @name tag forces JSDoc to associate the remainder of the JSDoc comment with the given name, ignoring all surrounding code. This tag is best used in "virtual comments" for symbols that are not readily visible in the code, such as methods that are generated at runtime.

当你使用 @name 标签时,你必须提供额外的标签来告诉 JSDoc 你正在记录的符号类型;是否该符号是另一个符号的成员;等等。如果你不提供这些信息,该符号将不会被正确记录。

🌐 When you use the @name tag, you must provide additional tags that tell JSDoc what kind of symbol you are documenting; whether the symbol is a member of another symbol; and so on. If you do not provide this information, the symbol will not be documented correctly.

警告:通过使用 @name 标签,你是在告诉 JSDoc 忽略周围的代码 并单独处理你的文档注释。在很多情况下,最好使用 @别名 标签,它会在文档中更改符号的名称,但保留关于该符号的其他信息。

示例

🌐 Examples

下面的示例演示了如何使用 @name 标签来记录一个 JSDoc 通常不会识别的函数。

🌐 The following example shows how to use the @name tag to document a function that JSDoc would not normally recognize.

使用 @name 标签
/**
 * @name highlightSearchTerm
 * @function
 * @global
 * @param {string} term - The search term to highlight.
 */
eval("window.highlightSearchTerm = function(term) {};")