Method: JsDuck::Merger#detect_doc_type

Defined in:
lib/jsduck/merger.rb

#detect_doc_type(docs, code) ⇒ Object

Detects whether the doc-comment is for class, cfg, event, method or property.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/jsduck/merger.rb', line 42

def detect_doc_type(docs, code)
  doc_map = build_doc_map(docs)

  if doc_map[:class]
    :class
  elsif doc_map[:event]
    :event
  elsif doc_map[:method]
    :method
  elsif doc_map[:property] || doc_map[:type]
    :property
  elsif doc_map[:css_var]
    :css_var
  elsif doc_map[:cfg] && doc_map[:cfg].length == 1
    # When just one @cfg, avoid treating it as @class
    :cfg
  elsif code[:type] == :ext_define
    :class
  elsif code[:type] == :assignment && class_name?(*code[:left])
    :class
  elsif code[:type] == :function && class_name?(code[:name])
    :class
  elsif code[:type] == :css_mixin
    :css_mixin
  elsif doc_map[:cfg]
    :cfg
  elsif code[:type] == :function
    :method
  elsif code[:type] == :assignment && code[:right] && code[:right][:type] == :function
    :method
  elsif doc_map[:return] || doc_map[:param]
    :method
  else
    :property
  end
end