加载中...

@variation


描述: 区分具有相同名称的不同的对象。

语法

@variation <variationNumber>

概述

有时候,你的代码可能包括多个同longname的标识符。 例如,你可能有两个全局类,并且顶级的命名空间叫做Widget。 在这些情况下, "{@link Widget}" 或者 "@memberof Widget" 是什么意思呢?全局命名空间,还是全局类?

@variatio有助于JSDoc区分相同longname的不同标识符。例如,如果"@variation 2"被添加到JSDoc注释块中的Widget类,"{@link Widget(2)}"将指向这个类,"{@link Widget}"将指向命名空间。此外,当你使用@alias 或 @name标签指定标识符的时候,还可以包括variatio (例如,"@alias Widget(2)")。

您可以给@variation标签提供任何值,只要值和longname组合导致全球唯一的longname的版本。最佳做法是,用一个可预测的模式进行选择值,这将使它更容易为您记录您的代码。

例子

下面的示例使用@variation标签来区分Widget类和Widget命名空间。

例如,使用@variation标签:

  1. /**
  2. * The Widget namespace.
  3. * @namespace Widget
  4. */
  5. // you can also use '@class Widget(2)' and omit the @variation tag
  6. /**
  7. * The Widget class. Defaults to the properties in {@link Widget.properties}.
  8. * @class
  9. * @variation 2
  10. * @param {Object} props - Name-value pairs to add to the widget.
  11. */
  12. function Widget(props) {}
  13. /**
  14. * Properties added by default to a new {@link Widget(2)} instance.
  15. */
  16. Widget.properties = {
  17. /**
  18. * Indicates whether the widget is shiny.
  19. */
  20. shiny: true,
  21. /**
  22. * Indicates whether the widget is metallic.
  23. */
  24. metallic: true
  25. };

还没有评论.