Commit ee160d3c authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Ignore @override that's not followed by class name.

For backwards compatibility with old ExtJS sources that contain
@override to denote a method is overriding another one in parent.
parent 5bbcbaac
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -77,6 +77,11 @@ module JsDuck
      @tags << @current_tag = {:tagname => tag, :doc => ""}
    end

    def remove_last_tag
      @tags.pop
      @current_tag = @tags.last
    end

    def parse_loop
      add_tag(:default)
      while !@input.eos? do
@@ -302,6 +307,14 @@ module JsDuck
      add_tag(:override)
      maybe_ident_chain(:class)
      skip_white

      # When @override not followed by class name, ignore the tag.
      # That's because the current ext codebase has some methods
      # tagged with @override to denote they override something.
      # But that's not what @override is meant for in JSDuck.
      unless @current_tag[:class]
        remove_last_tag
      end
    end

    # matches @type {type}  or  @type type
+18 −0
Original line number Diff line number Diff line
@@ -285,4 +285,22 @@ describe JsDuck::Aggregator do
      methods["foobar"][:doc].should == "**Overridden in blah.js.**"
    end
  end

  describe "@override without classname" do
    let(:classes) do
      parse(<<-EOF)
        /** */
        Ext.define("Foo", {
            /** @override */
            foo: function() { }
        });
      EOF
    end

    let(:methods) { create_members_map(classes["Foo"]) }

    it "gets ignored" do
      methods["foo"].should_not == nil
    end
  end
end