Loading lib/jsduck/js/class.rb +2 −2 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ module JsDuck when "inheritableStatics" cls[:members] += make_statics(value, {:inheritable => true}) else detect_method_or_property(cls, key, value, pair) detect_method_or_property(cls, key, value, pair) if pair.raw["kind"] == "init" end end end Loading @@ -132,7 +132,7 @@ module JsDuck def detect_class_members_from_object(cls, ast) cls[:members] = [] ast.each_property do |key, value, pair| detect_method_or_property(cls, key, value, pair) detect_method_or_property(cls, key, value, pair) if pair.raw["kind"] == "init" end end Loading lib/jsduck/js/method.rb +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ module JsDuck make(exp["id"].to_s || "", exp) # foo: function() {} elsif ast.property? && ast["value"].function? elsif ast.property? && ast.raw["kind"] == "init" && ast["value"].function? make(ast["key"].key_value, ast["value"]) # Object.defineProperty(obj, "prop", {value: function() {} }) Loading spec/aggregator_property_spec.rb +66 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,52 @@ describe JsDuck::Aggregator do it_should_behave_like "example property" end shared_examples_for "accessor property" do it "creates property" do @doc[:tagname].should == :property end it "detects name" do @doc[:name].should == "foo" end it "detects type as default" do @doc[:type].should == "Object" end end describe "doc-comment before a setter function" do before do @doc = parse_member(<<-EOS) ({ /** * Some documentation. */ set foo(x) { this.x = x; } }); EOS end it_should_behave_like "accessor property" end describe "doc-comment before a getter function" do before do @doc = parse_member(<<-EOS) ({ /** * Some documentation. */ get foo() { return this.x; } }); EOS end it_should_behave_like "accessor property" end shared_examples_for "auto type" do it "should imply correct type" do @doc[:type].should == @type Loading Loading @@ -335,4 +381,24 @@ describe JsDuck::Aggregator do end end describe "getter and setter properties inside object literal" do let(:members) do parse(<<-EOS)["MyClass"][:members] /** Some documentation. */ MyClass = { get foo() { return this.x; }, set foo(x) { this.x = x; } }; EOS end it "are all ignored" do members.length.should == 0 end end end Loading
lib/jsduck/js/class.rb +2 −2 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ module JsDuck when "inheritableStatics" cls[:members] += make_statics(value, {:inheritable => true}) else detect_method_or_property(cls, key, value, pair) detect_method_or_property(cls, key, value, pair) if pair.raw["kind"] == "init" end end end Loading @@ -132,7 +132,7 @@ module JsDuck def detect_class_members_from_object(cls, ast) cls[:members] = [] ast.each_property do |key, value, pair| detect_method_or_property(cls, key, value, pair) detect_method_or_property(cls, key, value, pair) if pair.raw["kind"] == "init" end end Loading
lib/jsduck/js/method.rb +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ module JsDuck make(exp["id"].to_s || "", exp) # foo: function() {} elsif ast.property? && ast["value"].function? elsif ast.property? && ast.raw["kind"] == "init" && ast["value"].function? make(ast["key"].key_value, ast["value"]) # Object.defineProperty(obj, "prop", {value: function() {} }) Loading
spec/aggregator_property_spec.rb +66 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,52 @@ describe JsDuck::Aggregator do it_should_behave_like "example property" end shared_examples_for "accessor property" do it "creates property" do @doc[:tagname].should == :property end it "detects name" do @doc[:name].should == "foo" end it "detects type as default" do @doc[:type].should == "Object" end end describe "doc-comment before a setter function" do before do @doc = parse_member(<<-EOS) ({ /** * Some documentation. */ set foo(x) { this.x = x; } }); EOS end it_should_behave_like "accessor property" end describe "doc-comment before a getter function" do before do @doc = parse_member(<<-EOS) ({ /** * Some documentation. */ get foo() { return this.x; } }); EOS end it_should_behave_like "accessor property" end shared_examples_for "auto type" do it "should imply correct type" do @doc[:type].should == @type Loading Loading @@ -335,4 +381,24 @@ describe JsDuck::Aggregator do end end describe "getter and setter properties inside object literal" do let(:members) do parse(<<-EOS)["MyClass"][:members] /** Some documentation. */ MyClass = { get foo() { return this.x; }, set foo(x) { this.x = x; } }; EOS end it "are all ignored" do members.length.should == 0 end end end