Class: JsDuck::Tag::Type

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

Constant Summary

Constants inherited from Tag

JsDuck::Tag::Tag::POS_ASIDE, JsDuck::Tag::Tag::POS_DEFAULT, JsDuck::Tag::Tag::POS_DEPRECATED, JsDuck::Tag::Tag::POS_DOC, JsDuck::Tag::Tag::POS_ENUM, JsDuck::Tag::Tag::POS_FIRES, JsDuck::Tag::Tag::POS_LOCALDOC, JsDuck::Tag::Tag::POS_OVERRIDES, JsDuck::Tag::Tag::POS_PARAM, JsDuck::Tag::Tag::POS_PREVENTABLE, JsDuck::Tag::Tag::POS_PRIVATE, JsDuck::Tag::Tag::POS_RETURN, JsDuck::Tag::Tag::POS_SINCE, JsDuck::Tag::Tag::POS_SUBPROPERTIES, JsDuck::Tag::Tag::POS_TEMPLATE, JsDuck::Tag::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, #parse_ext_define, #to_html

Constructor Details

#initializeType

Returns a new instance of Type.



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

def initialize
  @pattern = "type"
  @tagname = :type

  # We don't really care about the position as we don't output any
  # HTML. We just need to set this up to do the formatting.
  @html_position = POS_DOC
end

Instance Method Details

#curlyless_type(p) ⇒ Object



25
26
27
# File 'lib/jsduck/tag/type.rb', line 25

def curlyless_type(p)
  p.match(/\S+/)
end

#format(m, formatter) ⇒ Object



33
34
35
# File 'lib/jsduck/tag/type.rb', line 33

def format(m, formatter)
  m[:html_type] = formatter.format_type(m[:type])
end

#parse_doc(p, pos) ⇒ Object

matches @type type or @type type

The presence of @type implies that we are dealing with property. ext-doc allows type name to be either inside curly braces or without them at all.



19
20
21
22
23
# File 'lib/jsduck/tag/type.rb', line 19

def parse_doc(p, pos)
  tag = p.standard_tag({:tagname => :type, :type => true, :optional => true})
  tag[:type] = curlyless_type(p) unless tag[:type]
  tag
end

#process_doc(h, tags, pos) ⇒ Object



29
30
31
# File 'lib/jsduck/tag/type.rb', line 29

def process_doc(h, tags, pos)
  h[:type] = tags[0][:type] unless h[:type]
end