同义词
host
语法
@external <NameOfExternal>
概述
@external
标记标识当前包外部定义的类、命名空间或模块。通过使用此标记,您可以记录包对外部符号的扩展,或者可以向包的用户提供有关外部符号的信息。您还可以在任何其他 JSDoc 标记中引用外部符号的名称路径。
外部符号的名称路径始终使用前缀 external:
(例如,{@link external:Foo}
或 @augments external:Foo
)。但是,您可以从 @external
标记中省略此前缀。
注意:您应该只将 @external
标记添加到在项目外部定义的最高级别符号。有关示例,请参见“记录嵌套外部符号”。
示例
以下示例演示如何将内置 String
对象记录为外部对象,以及新的实例方法 external:String#rot13
/**
* The built in string object.
* @external String
* @see {@link https://mdn.org.cn/en-US/docs/Web/JavaScript/Reference/Global_Objects/String|String}
*/
/**
* Create a ROT13-encoded version of the string. Added by the `foo` package.
* @function external:String#rot13
* @example
* var greeting = new String('hello world');
* console.log( greeting.rot13() ); // uryyb jbeyq
*/
以下示例记录添加到外部命名空间 "jQuery.fn"
的新 starfairy
函数
/**
* The jQuery plugin namespace.
* @external "jQuery.fn"
* @see {@link https://learn.jqueryjs.cn/plugins/|jQuery Plugins}
*/
/**
* A jQuery plugin to make stars fly around your home page.
* @function external:"jQuery.fn".starfairy
*/
在以下示例中,类 EncryptedRequest
被记录为内置类 XMLHttpRequest
的子类
/**
* The built-in class for sending HTTP requests.
* @external XMLHttpRequest
* @see https://mdn.org.cn/en-US/docs/Web/API/XMLHttpRequest
*/
/**
* Extends the built-in `XMLHttpRequest` class to send data encoded with a secret key.
* @class EncodedRequest
* @extends external:XMLHttpRequest
*/
您应该只将 @external
标记添加到在项目外部定义的最高级别符号。在以下示例中,文档引用外部类 security.TLS
。因此,@external
标记用于记录外部命名空间 external:security
,但不用于记录外部类 external:security.TLS
。
/**
* External namespace for security-related classes.
* @external security
* @see http://example.org/docs/security
*/
/**
* External class that provides Transport Layer Security (TLS) encryption.
* @class TLS
* @memberof external:security
*/