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

Detect doc-comments with @param and @return as methods.

parent 72055801
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ module JsDuck
        :cfg
      elsif doc_map[:constructor]
        :method
      elsif doc_map[:param] || doc_map[:return]
        :method
      else
        code[:tagname]
      end
+16 −0
Original line number Diff line number Diff line
@@ -45,6 +45,14 @@ describe JsDuck::DocType do
      detect("/** @constructor */").should == :method
    end

    it "@param tag" do
      detect("/** @param {Number} x */").should == :method
    end

    it "@return tag" do
      detect("/** @return {Boolean} */").should == :method
    end

    it "function declaration" do
      detect("/** */ function foo() {}").should == :method
    end
@@ -54,6 +62,10 @@ describe JsDuck::DocType do
    it "@event tag" do
      detect("/** @event */").should == :event
    end

    it "@event and @param tags" do
      detect("/** @event @param {Number} x */").should == :event
    end
  end

  describe "detects as config" do
@@ -86,6 +98,10 @@ describe JsDuck::DocType do
    it "@mixin in code" do
      detect("/** */ @mixin foo-bar {}", :css).should == :css_mixin
    end

    it "@param in doc and @mixin in code" do
      detect("/** @param {number} $foo */ @mixin foo-bar {}", :css).should == :css_mixin
    end
  end

end