Commit 5e5e6270 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support for @event.

parent 54b9b2ec
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ module JsDuck
          at_class
        elsif look(/@extends\b/) then
          at_extends
        elsif look(/@event\b/) then
          at_event
        elsif look(/@function\b/) then
          at_function
        elsif look(/@param\b/) then
@@ -130,6 +132,17 @@ module JsDuck
      skip_white
    end

    # matches @event name ...
    def at_event
      match(/@event/)
      @current_tag = @tags[:event] = {:doc => ""}
      skip_white
      if look(/\w/) then
        @current_tag[:name] = ident
      end
      skip_white
    end

    # matches @return {type} ...
    def at_function
      match(/@function/)
+9 −0
Original line number Diff line number Diff line
@@ -39,6 +39,15 @@ class TestDocComment < Test::Unit::TestCase
    assert_equal("Some docs.", doc[:class][:doc])
  end

  def test_event
    doc = JsDuck::DocComment.new("/**
 * @event mousedown
 * Fires when the mouse button is depressed.
 */")
    assert_equal("mousedown", doc[:event][:name])
    assert_equal("Fires when the mouse button is depressed.", doc[:event][:doc])
  end

  def test_long_docs
    doc = JsDuck::DocComment.new("/**
 * @function foo
+1 −1

File changed.

Contains only whitespace changes.