Class: JsDuck::Tag::ClassListTag

Inherits:
Tag
  • Object
show all
Defined in:
lib/jsduck/tag/class_list_tag.rb

Overview

Base class for tags like @mixins, @uses, etc Which take the following form:

@tagname classname1 classname2 ...

Subclasses need to define the @patterns and @tagname fields for the #parse_doc and #process_doc methods to work. Plus #parse_ext_define to work.

Direct Known Subclasses

AlternateClassNames, Mixins, Requires, Uses

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

Instance Attribute Summary

Attributes inherited from Tag

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

Instance Method Summary collapse

Methods inherited from Tag

descendants, #format, #to_html

Instance Method Details

#classname_list(p) ⇒ Object

matches <ident_chain> <ident_chain> … until line end



24
25
26
27
28
29
30
# File 'lib/jsduck/tag/class_list_tag.rb', line 24

def classname_list(p)
  classes = []
  while cls = p.hw.ident_chain
    classes << cls
  end
  classes
end

#parse_doc(p, pos) ⇒ Object



16
17
18
19
20
21
# File 'lib/jsduck/tag/class_list_tag.rb', line 16

def parse_doc(p, pos)
  {
    :tagname => @tagname,
    :classes => classname_list(p),
  }
end

#parse_ext_define(cls, ast) ⇒ Object



36
37
38
# File 'lib/jsduck/tag/class_list_tag.rb', line 36

def parse_ext_define(cls, ast)
  cls[@tagname] = JsDuck::Js::Utils.make_string_list(ast)
end

#process_doc(h, tags, pos) ⇒ Object



32
33
34
# File 'lib/jsduck/tag/class_list_tag.rb', line 32

def process_doc(h, tags, pos)
  h[@tagname] = tags.map {|d| d[:classes] }.flatten
end