Class: JsDuck::Js::Event

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

Overview

Auto-detection of events.

Instance Method Summary collapse

Methods included from Util::Singleton

included

Instance Method Details

#detect(ast) ⇒ Object

Checks if AST node is an event, and if so, returns doc-hash with event name and various auto-detected properties. When not an event returns nil.



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

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

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

#make(name) ⇒ Object

Produces a doc-hash for an event.



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

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