Class: JsDuck::Tag::Mixins

Inherits:
ClassListTag show all
Defined in:
lib/jsduck/tag/mixins.rb

Constant Summary

Constants inherited from Tag

Tag::POS_ASIDE, Tag::POS_DEFAULT, Tag::POS_DEPRECATED, Tag::POS_DOC, Tag::POS_ENUM, Tag::POS_FIRES, Tag::POS_LOCALDOC, Tag::POS_OVERRIDES, Tag::POS_PARAM, Tag::POS_PREVENTABLE, Tag::POS_PRIVATE, Tag::POS_RETURN, Tag::POS_SINCE, Tag::POS_SUBPROPERTIES, Tag::POS_TEMPLATE, Tag::POS_THROWS, Tag::PRIORITY_CLASS, Tag::PRIORITY_COMPONENT, Tag::PRIORITY_SINGLETON

Instance Attribute Summary

Attributes inherited from Tag

#class_icon, #css, #ext_define_default, #ext_define_pattern, #html_position, #pattern, #repeatable, #signature, #tagname

Instance Method Summary collapse

Methods inherited from ClassListTag

#classname_list, #parse_doc, #process_doc

Methods inherited from Tag

descendants, #format, #parse_doc, #process_doc, #to_html

Constructor Details

#initializeMixins

Returns a new instance of Mixins.



5
6
7
8
9
10
11
# File 'lib/jsduck/tag/mixins.rb', line 5

def initialize
  @pattern = ["mixin", "mixins"]
  @tagname = :mixins
  @repeatable = true
  @ext_define_pattern = "mixins"
  @ext_define_default = {:mixins => []}
end

Instance Method Details

#parse_ext_define(cls, ast) ⇒ Object

Override definition in parent class. In addition to Array literal, mixins can be defined with an object literal.



15
16
17
# File 'lib/jsduck/tag/mixins.rb', line 15

def parse_ext_define(cls, ast)
  cls[:mixins] = to_mixins_array(ast)
end

#to_mixins_array(ast) ⇒ Object

converts AstNode, whether it’s a string, array or hash into array of strings (when possible).



21
22
23
24
25
# File 'lib/jsduck/tag/mixins.rb', line 21

def to_mixins_array(ast)
  v = ast.to_value
  mixins = v.is_a?(Hash) ? v.values : Array(v)
  mixins.all? {|mx| mx.is_a? String } ? mixins : []
end