class JsDuck::Js::Listener
Auto-detection of listeners.
Public Instance Methods
detect(ast)
click to toggle source
Checks if AST node is a listener, and if so, returns doc-hash with listener name and various auto-detected properties. When not an listener returns nil. Note: currently this is not implemented. Needs to check for methods under the “listeners:” item
# 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)
click to toggle source
Produces a doc-hash for an listener.
# File lib/jsduck/js/listener.rb, line 26 def make(name) return { :tagname => :listener, :name => name, } end