语法
¥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 忽略周围的代码并单独处理你的文档注释。在许多情况下,最好改用 @alias tag,它会更改文档中符号的名称,但保留有关符号的其他信息。
¥Warning: By using the @name tag, you are telling JSDoc to ignore the surrounding code and treat your documentation comment in isolation. In many cases, it is best to use the @alias tag instead, which changes a symbol's name in the documentation but preserves other information about the symbol.
示例
¥Examples
以下示例演示如何使用 @name 标记来记录 JSDoc 通常无法识别的函数。
¥The following example shows how to use the @name tag to document a function that JSDoc would not normally recognize.
/**
* @name highlightSearchTerm
* @function
* @global
* @param {string} term - The search term to highlight.
*/
eval("window.highlightSearchTerm = function(term) {};")