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

Added @extends.

parent 61a57bcb
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -154,6 +154,8 @@ module JsDuck
      while !@input.eos? do
        if look(/@class\b/) then
          at_class
        elsif look(/@extends\b/) then
          at_extends
        elsif look(/@function\b/) then
          at_function
        elsif look(/@param\b/) then
@@ -179,6 +181,20 @@ module JsDuck
      skip_white
    end

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

    # matches @return {type} ...
    def at_function
      match(/@function/)
+13 −0
Original line number Diff line number Diff line
@@ -225,5 +225,18 @@ function Foo(){}
    assert_equal("My class", docs[0][:class][:doc])
  end

  def test_explicit_extends
    docs = JsDuck.parse("
/**
 * @class Foo
 * @extends Bar
 * My class
 */
")
    assert_equal("Foo", docs[0][:class][:name])
    assert_equal("Bar", docs[0][:class][:extends])
    assert_equal("My class", docs[0][:class][:doc])
  end

end