加载中...

@external


描述:标识一个外部的类,命名空间,或模块。

别名: @host

Syntax(语法)

@external <NameOfExternal>

Overview(概述)

@external标签用来标识一个在当前包外部定义的类,命名空间,或模块。通过使用这个标签,你可以描述你的包的外部标识的扩展,或者您也可以提供关于 外部标识的相关信息给你的包的使用者。你也可以在任何其他JSDoc标签中引用外部标识的namepath(名称路径)。

外部标识引用的路径名 始终需要使用external:前缀:(例如{@link external:Foo}@augments external:Foo)。 但是,你可以省略@external标记的这个前缀。

注意:您只能在你的项目之外定义的最高级别的标识上添加@external标签,请参见“描述一个嵌套的外部标识”的例子。

Examples(例子)

下面的示例演示如何描述内置的String对象作为external,新的实例方法external:String#rot13

例如,描述内置类添加方法:

  1. /**
  2. * The built in string object.
  3. * @external String
  4. * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String|String}
  5. */
  6. /**
  7. * Create a ROT13-encoded version of the string. Added by the `foo` package.
  8. * @function external:String#rot13
  9. * @example
  10. * var greeting = new String('hello world');
  11. * console.log( greeting.rot13() ); // uryyb jbeyq
  12. */

下面的例子中描述一个新starfairy功能如何添加到外部的jQuery.fn命名空间。

例如,描述的外部的命名空间:

  1. /**
  2. * The jQuery plugin namespace.
  3. * @external "jQuery.fn"
  4. * @see {@link http://learn.jquery.com/plugins/|jQuery Plugins}
  5. */
  6. /**
  7. * A jQuery plugin to make stars fly around your home page.
  8. * @function external:"jQuery.fn".starfairy
  9. */

在下面的例子中,EncryptedRequest类被描述为内置的XMLHttpRequest类的子类:

例如,扩展一个外部类:

  1. /**
  2. * The built-in class for sending HTTP requests.
  3. * @external XMLHttpRequest
  4. * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
  5. */
  6. /**
  7. * Extends the built-in `XMLHttpRequest` class to send data encoded with a secret key.
  8. * @class EncodedRequest
  9. * @extends external:XMLHttpRequest
  10. */

您只能将@external标签添加到您的是项目定义的最外最顶层。在下面的例子中,描述的是外部的security.TLS类。其结果是,@external标签是用来描述外部的external:security命名空间,而是外部类external:security.TLS

例如,记录一个嵌套的外部标识:

  1. /**
  2. * External namespace for security-related classes.
  3. * @external security
  4. * @see http://example.org/docs/security
  5. */
  6. /**
  7. * External class that provides Transport Layer Security (TLS) encryption.
  8. * @class TLS
  9. * @memberof external:security
  10. */

还没有评论.