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

Auto-detect method when @param or @return present.

It simply makes sense to not require adding @method when it's obvious
without it that it's a comment for method.
parent b9ba9464
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ module JsDuck
        :method
      elsif code[:type] == :assignment && code[:right] && code[:right][:type] == :function
        :method
      elsif doc_map[:return] || doc_map[:param]
        :method
      else
        :property
      end
+26 −0
Original line number Diff line number Diff line
@@ -264,6 +264,32 @@ describe JsDuck::Aggregator do
    it_should_behave_like "has return"
  end

  describe "Doc-comment not followed by function but containing @return" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * Some function
         * @returns {String} return value
         */
        var foo = Ext.emptyFn;
      EOS
    end
    it_should_behave_like "method documentation"
  end

  describe "Doc-comment not followed by function but containing @param" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * Some function
         * @param {String} x
         */
        var foo = Ext.emptyFn;
      EOS
    end
    it_should_behave_like "method documentation"
  end

  describe "method without doc-comment" do
    before do
      @docs = parse(<<-EOS)