Commit 9bd94156 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow configs begin with uppercase letter.

Previously all @cfgs beginning with uppercase letter were treated
as classes, because a class definition can also contain @cfg tags.
Now we only treat it as class definition when there is more than
one @cfg inside one doc-comment.
parent b2d2e753
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ module JsDuck
        :property
      elsif doc_map[:css_var]
        :css_var
      elsif doc_map[:cfg] && doc_map[:cfg].length == 1
        # When just one @cfg, avoid treating it as @class
        :cfg
      elsif code[:type] == :ext_define
        :class
      elsif code[:type] == :assignment && class_name?(*code[:left])
+25 −0
Original line number Diff line number Diff line
@@ -144,6 +144,31 @@ describe JsDuck::Aggregator do
    end
  end

  describe "@cfg with uppercase name" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * @cfg {String} Foo
         */
        Foo: 12
      EOS
    end
    it_should_behave_like "cfg"
  end

  describe "@cfg with uppercase name after description" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * Docs here
         * @cfg {String} Foo
         */
        Foo: 12
      EOS
    end
    it_should_behave_like "cfg"
  end

  shared_examples_for "auto type" do
    it "should imply correct type" do
      @doc[:type].should == @type
+14 −0
Original line number Diff line number Diff line
@@ -305,6 +305,20 @@ describe JsDuck::Aggregator do
    end
  end

  describe "implicit class with more than one cfg" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * Comment here.
         * @cfg {String} foo
         * @cfg {String} bar
         */
        MyClass = function() {}
      EOS
    end
    it_should_behave_like "class"
  end

  describe "class with constructor" do
    before do
      @doc = parse(<<-EOS)[0]