Class: JsDuck::Tag::Param

Inherits:
Tag
  • Object
show all
Defined in:
lib/jsduck/tag/param.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

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

Constructor Details

#initializeParam

Returns a new instance of Param.



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

def initialize
  @pattern = "param"
  @tagname = :params
  @repeatable = true
  @html_position = POS_PARAM
end

Instance Method Details

#format(m, formatter) ⇒ Object



37
38
39
# File 'lib/jsduck/tag/param.rb', line 37

def format(m, formatter)
  m[:params].each {|p| formatter.format_subproperty(p) }
end

#parse_doc(p, pos) ⇒ Object

Parameters:

  • [name=default] (Type)

    (optional) …



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jsduck/tag/param.rb', line 15

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

#parse_optional(p) ⇒ Object



28
29
30
# File 'lib/jsduck/tag/param.rb', line 28

def parse_optional(p)
  p.hw.match(/\(optional\)/i)
end

#process_doc(h, tags, pos) ⇒ Object



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

def process_doc(h, tags, pos)
  h[:params] = JsDuck::Doc::Subproperties.nest(tags, pos)
  h[:params] = nil if h[:params].length == 0
end

#to_html(m) ⇒ Object



41
42
43
# File 'lib/jsduck/tag/param.rb', line 41

def to_html(m)
  JsDuck::Render::Subproperties.render_params(m[:params]) if m[:params].length > 0
end