JSDoc 中文网

语法

🌐 Syntax

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

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

@private

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

🌐 With the Closure Compiler tag dictionary:

@private [{typeExpression}]

概述

🌐 Overview

@private 标签将符号标记为私有,或者不用于通用用途。私有成员在生成的输出中不会显示,除非 JSDoc 使用 -p/--private 命令行选项运行。在 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
};