class JsDuck::Js::Event

Auto-detection of events.

Public Instance Methods

detect(ast) click to toggle source

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.

# 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) click to toggle source

Produces a doc-hash for an event.

# File lib/jsduck/js/event.rb, line 25
def make(name)
  return {
    :tagname => :event,
    :name => name,
  }
end