@name¶
-
.. @name::
¶ - 语法
@name <namePath>
- 概述
@name标记强制JSDoc将JSDoc注释的其余部分与给定名称相关联, 忽略所有周围的代码. 对于在代码中不易看到的符号(例如在运行时生成的方法), 此标记最好用于“虚拟注释”.
当您使用@name标记时, 您必须提供其他标记, 告诉JSDoc您正在记录哪种符号;符号是否是另一个符号的成员;等等. 如果您不提供此信息, 则无法正确记录该符号.
警告
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]
alias
instead, which changes a symbol’s name in the documentation but preserves other information about the symbol.- 示例
以下示例显示如何使用@name标记来记录JSDoc通常无法识别的函数.
Using the @name tag¶/** * @name highlightSearchTerm * @function * @global * @param {string} term - The search term to highlight. */ eval("window.highlightSearchTerm = function(term) {};")