class JsDuck::Tag::Property

Public Class Methods

new() click to toggle source
# 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

Public Instance Methods

merge(h, docs, code) click to toggle source

Do the merging of :type field

# 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) click to toggle source

@property {Type} [name=default] …

# 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) click to toggle source
Calls superclass method JsDuck::Tag::MemberTag#process_code
# 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) click to toggle source
# 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) click to toggle source
# File lib/jsduck/tag/property.rb, line 63
def to_html(property, cls)
  member_link(property) + " : " + property[:html_type]
end