Commit 150ea229 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Detect @constructor tag as a method.

Unless it appears inside class doc-comment.
parent c6b83055
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ module JsDuck
        :css_mixin
      elsif doc_map[:cfg]
        :cfg
      elsif doc_map[:constructor]
        :method
      else
        code[:tagname]
      end
+19 −0
Original line number Diff line number Diff line
@@ -61,4 +61,23 @@ describe JsDuck::Aggregator do
    it_should_behave_like "constructor"
  end

  describe "class with member containing @constructor" do
    let(:methods) do
      parse(<<-EOS)[0][:members][:method]
        /**
         * Comment here.
         */
        MyClass = {
            /**
             * @constructor
             * This constructs the class
             * @param {Number} nr
             */
        };
      EOS
    end

    it_should_behave_like "constructor"
  end

end
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@ describe JsDuck::DocType do
      detect("/** @method */").should == :method
    end

    it "@constructor tag" do
      detect("/** @constructor */").should == :method
    end

    it "function declaration" do
      detect("/** */ function foo() {}").should == :method
    end