Class: JsDuck::Tag::Class

Inherits:
Tag
  • Object
show all
Defined in:
lib/jsduck/tag/class.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, Tag::PRIORITY_CLASS, Tag::PRIORITY_COMPONENT, Tag::PRIORITY_SINGLETON

Instance Attribute Summary

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 Tag

descendants, #format, #parse_ext_define, #to_html

Constructor Details

#initializeClass

Returns a new instance of Class.



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

def initialize
  @pattern = "class"
  @tagname = :class
  @class_icon = {
    :small => File.dirname(__FILE__) + "/icons/class.png",
    :large => File.dirname(__FILE__) + "/icons/class-large.png",
    :redirect => File.dirname(__FILE__) + "/icons/class-redirect.png",
    :priority => PRIORITY_CLASS,
  }
end

Instance Method Details

#merge(h, docs, code) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/jsduck/tag/class.rb', line 41

def merge(h, docs, code)
  # Ensure the empty members array.
  h[:members] = []
  # Ignore extending of the Object class
  h[:extends] = nil if h[:extends] == "Object"
  # Default alternateClassNames list to empty array
  h[:alternateClassNames] = [] unless h[:alternateClassNames]
  # Turn :aliases field into hash
  h[:aliases] = build_aliases_hash(h[:aliases] || [])

  # Takes the :enum always from docs, but the :doc_only can come
  # from either code or docs.
  if docs[:enum]
    h[:enum] = docs[:enum]
    h[:enum][:doc_only] = docs[:enum][:doc_only] || (code[:enum] && code[:enum][:doc_only])
  end
end

#parse_doc(p, pos) ⇒ Object



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

def parse_doc(p, pos)
  {
    :tagname => :class,
    :name => p.ident_chain,
  }
end

#process_code(code) ⇒ Object

Although class is not a member, it also has the auto-detected part from code. So this method gets called by Merger.

If we did detect code as a class use all the auto-detected fields, otherwise use only the name field.



33
34
35
36
37
38
39
# File 'lib/jsduck/tag/class.rb', line 33

def process_code(code)
  if code[:tagname] == :class
    code
  else
    {:name => code[:name] }
  end
end

#process_doc(h, tags, pos) ⇒ Object



24
25
26
# File 'lib/jsduck/tag/class.rb', line 24

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