Class: JsDuck::Js::Listener

Inherits:
Object
  • Object
show all
Includes:
Util::Singleton
Defined in:
lib/jsduck/js/listener.rb

Overview

Auto-detection of listeners.

Instance Method Summary collapse

Methods included from Util::Singleton

included

Instance Method Details

#detect(ast) ⇒ Object

Note: currently this is not implemented. Needs to check for methods under the “listeners:” item



14
15
16
17
18
19
20
21
22
23
# File 'lib/jsduck/js/listener.rb', line 14

def detect(ast)
  exp = ast.expression_statement? ? ast["expression"] : nil

  # this.fireEvent("foo", ...)
  if exp && 1==2
    make(exp["arguments"][0].to_value)
  else
    nil
  end
end

#make(name) ⇒ Object

Produces a doc-hash for an listener.



26
27
28
29
30
31
# File 'lib/jsduck/js/listener.rb', line 26

def make(name)
  return {
    :tagname => :listener,
    :name => name,
  }
end