Class: JsDuck::Tag::Property

Inherits:
MemberTag show all
Defined in:
lib/jsduck/tag/property.rb

Constant Summary

Constants inherited from MemberTag

MemberTag::MEMBER_POS_CFG, MemberTag::MEMBER_POS_CSS_MIXIN, MemberTag::MEMBER_POS_CSS_VAR, MemberTag::MEMBER_POS_EVENT, MemberTag::MEMBER_POS_LISTENER, MemberTag::MEMBER_POS_METHOD, MemberTag::MEMBER_POS_PROPERTY

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 MemberTag

#member_type

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 MemberTag

#member_link, #member_params

Methods inherited from Tag

descendants, #format, #parse_ext_define

Constructor Details

#initializeProperty

Returns a new instance of Property.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jsduck/tag/property.rb', line 6

def initialize
  @pattern = "property"
  @tagname = :property
  @repeatable = true
  @member_type = {
    :title => "Properties",
    :position => MEMBER_POS_PROPERTY,
    :icon => File.dirname(__FILE__) + "/icons/property.png",
    :subsections => [
      {:title => "Instance properties", :filter => {:static => false}, :default => true},
      {:title => "Static properties", :filter => {:static => true}},
    ]
  }
end

Instance Method Details

#merge(h, docs, code) ⇒ Object

Do the merging of :type field



57
58
59
60
61
# File 'lib/jsduck/tag/property.rb', line 57

def merge(h, docs, code)
  if h[:type] == nil
    h[:type] = code[:tagname] == :method ? "Function" : "Object"
  end
end

#parse_doc(p, pos) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jsduck/tag/property.rb', line 22

def parse_doc(p, pos)
  tag = p.standard_tag({
      :tagname => :property,
      :type => true,
      :name => true,
      :default => true,
      :optional => true
    })
  tag[:doc] = :multiline
  tag
end

#process_code(code) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/jsduck/tag/property.rb', line 48

def process_code(code)
  h = super(code)
  h[:type] = code[:type]
  h[:default] = code[:default]
  h[:readonly] = code[:readonly]
  h
end

#process_doc(h, tags, pos) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/jsduck/tag/property.rb', line 34

def process_doc(h, tags, pos)
  p = tags[0]
  # Type might also come from @type, don't overwrite it with nil.
  h[:type] = p[:type] if p[:type]
  h[:default] = p[:default]

  # Documentation after the first @property is part of the top-level docs.
  h[:doc] += p[:doc]

  nested = JsDuck::Doc::Subproperties.nest(tags, pos)[0]
  h[:properties] = nested[:properties]
  h[:name] = nested[:name]
end

#to_html(property, cls) ⇒ Object



63
64
65
# File 'lib/jsduck/tag/property.rb', line 63

def to_html(property, cls)
  member_link(property) + " : " + property[:html_type]
end