JSDoc 中文网

语法

¥Syntax

使用 JSDoc 标签字典(默认启用):

¥With the JSDoc tag dictionary (enabled by default):

@private

使用 闭包编译器 标签字典:

¥With the Closure Compiler tag dictionary:

@private [{typeExpression}]

概述

¥Overview

@private 标签将符号标记为私有,或者不适合一般用途。除非使用 -p/--private 命令行选项运行 JSDoc,否则私有成员不会显示在生成的输出中。在 JSDoc 3.3.0 及更高版本中,你还可以使用 -a/--access 命令行选项 来更改此行为。

¥The @private tag marks a symbol as private, or not meant for general use. Private members are not shown in the generated output unless JSDoc is run with the -p/--private command-line option. In JSDoc 3.3.0 and later, you can also use the -a/--access command-line option to change this behavior.

@private 标签不会被子成员继承。例如,如果将 @private 标记添加到命名空间,则该命名空间的成员仍然可以出现在生成的输出中;由于命名空间是私有的,因此成员的名称路径将不包含命名空间。

¥The @private tag is not inherited by child members. For example, if the @private tag is added to a namespace, members of the namespace can still appear in the generated output; because the namespace is private, the members' namepath will not include the namespace.

@private 标签相当于 @access private

¥The @private tag is equivalent to @access private.

示例

¥Examples

在以下示例中,生成的文档中出现了 DocumentsDocuments.Newspaper,但没有出现 Documents.Diary

¥In the following example, Documents and Documents.Newspaper appear in the generated documentation, but not Documents.Diary.

使用@private 标签
/** @namespace */
var Documents = {
    /**

     * An ordinary newspaper.
     */
    Newspaper: 1,
    /**

     * My diary.

     * @private
     */
    Diary: 2
};