Commit 4705e26b authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support for normal comment detection for statics:.

parent d53f1f6e
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -293,16 +293,19 @@ module JsDuck
        s.merge!(defaults)

        docset = find_docset(p)
        if docset
          docset[:code] = s
        else

        if !docset || docset[:type] != :doc_comment
          if defaults[:inheritable]
            s[:inheritdoc] = {}
          else
            s[:private] = true
          end

          s[:autodetected] = true
        end

        if docset
          docset[:code] = s
        else
          s[:linenr] = p["range"][2]
          statics << s
        end
+28 −0
Original line number Diff line number Diff line
@@ -199,4 +199,32 @@ describe JsDuck::Aggregator do
    end
  end

  describe "Ext.define() with line-comment before item in statics:" do
    let(:methods) do
      parse(<<-EOS)[0][:statics][:method]
        /**
         * Some documentation.
         */
        Ext.define("MyClass", {
            statics: {
                // Check this out
                bar: function() {}
            }
        });
      EOS
    end

    it "detects one static method" do
      methods.length.should == 1
    end

    it "detects documentation" do
      methods[0][:doc].should == "Check this out"
    end

    it "detects the method with :autodetected flag" do
      methods[0][:autodetected].should == true
    end
  end

end