Loading lib/jsduck/importer.rb +2 −2 Original line number Diff line number Diff line Loading @@ -59,12 +59,12 @@ module JsDuck last_version = versions.last[:version] relations.each do |cls| v = class_since(versions, cls) v = cls[:meta][:since] || class_since(versions, cls) cls[:meta][:since] = v cls[:meta][:new] = true if v == last_version cls.all_local_members.each do |m| v = member_since(versions, cls, m) v = m[:meta][:since] || member_since(versions, cls, m) m[:meta][:since] = v m[:meta][:new] = true if v == last_version end Loading spec/importer_spec.rb +35 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ describe "JsDuck::Importer#generate_since_tags" do { :version => "1.0", :classes => { "VeryOldClass" => {"cfg-foo" => true}, "ExplicitNewClass" => {}, }, }, { Loading @@ -26,10 +27,16 @@ describe "JsDuck::Importer#generate_since_tags" do :cfg => [{:id => "cfg-foo", :meta => {}}], :method => [{:id => "cfg-bar", :meta => {}}], :event => [{:id => "event-baz", :meta => {}}], :property => [ {:id => "property-zap", :meta => {:since => "1.0"}}, {:id => "property-new", :meta => {:new => true}}, ], }}, {:name => "OldClass", :meta => {}, :alternateClassNames => []}, {:name => "NewClass", :meta => {}, :alternateClassNames => []}, {:name => "ClassWithNewName", :meta => {}, :alternateClassNames => ["ClassWithOldName"]}, {:name => "ExplicitClass", :meta => {:since => "1.0"}, :alternateClassNames => []}, {:name => "ExplicitNewClass", :meta => {:new => true}, :alternateClassNames => []}, ].map {|cfg| JsDuck::Class.new(cfg) } JsDuck::Importer.generate_since_tags(@versions, @relations) Loading @@ -53,6 +60,10 @@ describe "JsDuck::Importer#generate_since_tags" do @relations[3][:meta][:since].should == "2.0" end it "doesn't override explicit @since 1.0 in ExplicitClass" do @relations[4][:meta][:since].should == "1.0" end it "adds @since 1.0 to VeryOldClass#cfg-foo" do @relations[0][:members][:cfg][0][:meta][:since].should == "1.0" end Loading @@ -65,6 +76,10 @@ describe "JsDuck::Importer#generate_since_tags" do @relations[0][:members][:event][0][:meta][:since].should == "3.0" end it "doesn't override explicit @since 1.0 in VeryOldClass#property-zap" do @relations[0][:members][:property][0][:meta][:since].should == "1.0" end # @new it "doesn't add @new to VeryOldClass" do Loading @@ -83,6 +98,17 @@ describe "JsDuck::Importer#generate_since_tags" do @relations[3][:meta][:new].should_not == true end it "doesn't add @new to ExplicitClass" do @relations[4][:meta][:new].should_not == true end it "keeps explicit @new on ExplicitNewClass" do # Though it seems like a weird case, there could be a situation # where 1.0 had class Foo, which was removed in 2.0, but in 3.0 a # completely unrelated Foo class was introduced. @relations[5][:meta][:new].should == true end it "doesn't add @new to VeryOldClass#cfg-foo" do @relations[0][:members][:cfg][0][:meta][:new].should_not == true end Loading @@ -94,4 +120,13 @@ describe "JsDuck::Importer#generate_since_tags" do it "adds @new to VeryOldClass#event-baz" do @relations[0][:members][:event][0][:meta][:new].should == true end it "doesn't add @new to VeryOldClass#property-zap" do @relations[0][:members][:property][0][:meta][:new].should_not == true end it "keeps explicit @new in VeryOldClass#property-new" do @relations[0][:members][:property][1][:meta][:new].should == true end end Loading
lib/jsduck/importer.rb +2 −2 Original line number Diff line number Diff line Loading @@ -59,12 +59,12 @@ module JsDuck last_version = versions.last[:version] relations.each do |cls| v = class_since(versions, cls) v = cls[:meta][:since] || class_since(versions, cls) cls[:meta][:since] = v cls[:meta][:new] = true if v == last_version cls.all_local_members.each do |m| v = member_since(versions, cls, m) v = m[:meta][:since] || member_since(versions, cls, m) m[:meta][:since] = v m[:meta][:new] = true if v == last_version end Loading
spec/importer_spec.rb +35 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ describe "JsDuck::Importer#generate_since_tags" do { :version => "1.0", :classes => { "VeryOldClass" => {"cfg-foo" => true}, "ExplicitNewClass" => {}, }, }, { Loading @@ -26,10 +27,16 @@ describe "JsDuck::Importer#generate_since_tags" do :cfg => [{:id => "cfg-foo", :meta => {}}], :method => [{:id => "cfg-bar", :meta => {}}], :event => [{:id => "event-baz", :meta => {}}], :property => [ {:id => "property-zap", :meta => {:since => "1.0"}}, {:id => "property-new", :meta => {:new => true}}, ], }}, {:name => "OldClass", :meta => {}, :alternateClassNames => []}, {:name => "NewClass", :meta => {}, :alternateClassNames => []}, {:name => "ClassWithNewName", :meta => {}, :alternateClassNames => ["ClassWithOldName"]}, {:name => "ExplicitClass", :meta => {:since => "1.0"}, :alternateClassNames => []}, {:name => "ExplicitNewClass", :meta => {:new => true}, :alternateClassNames => []}, ].map {|cfg| JsDuck::Class.new(cfg) } JsDuck::Importer.generate_since_tags(@versions, @relations) Loading @@ -53,6 +60,10 @@ describe "JsDuck::Importer#generate_since_tags" do @relations[3][:meta][:since].should == "2.0" end it "doesn't override explicit @since 1.0 in ExplicitClass" do @relations[4][:meta][:since].should == "1.0" end it "adds @since 1.0 to VeryOldClass#cfg-foo" do @relations[0][:members][:cfg][0][:meta][:since].should == "1.0" end Loading @@ -65,6 +76,10 @@ describe "JsDuck::Importer#generate_since_tags" do @relations[0][:members][:event][0][:meta][:since].should == "3.0" end it "doesn't override explicit @since 1.0 in VeryOldClass#property-zap" do @relations[0][:members][:property][0][:meta][:since].should == "1.0" end # @new it "doesn't add @new to VeryOldClass" do Loading @@ -83,6 +98,17 @@ describe "JsDuck::Importer#generate_since_tags" do @relations[3][:meta][:new].should_not == true end it "doesn't add @new to ExplicitClass" do @relations[4][:meta][:new].should_not == true end it "keeps explicit @new on ExplicitNewClass" do # Though it seems like a weird case, there could be a situation # where 1.0 had class Foo, which was removed in 2.0, but in 3.0 a # completely unrelated Foo class was introduced. @relations[5][:meta][:new].should == true end it "doesn't add @new to VeryOldClass#cfg-foo" do @relations[0][:members][:cfg][0][:meta][:new].should_not == true end Loading @@ -94,4 +120,13 @@ describe "JsDuck::Importer#generate_since_tags" do it "adds @new to VeryOldClass#event-baz" do @relations[0][:members][:event][0][:meta][:new].should == true end it "doesn't add @new to VeryOldClass#property-zap" do @relations[0][:members][:property][0][:meta][:new].should_not == true end it "keeps explicit @new in VeryOldClass#property-new" do @relations[0][:members][:property][1][:meta][:new].should == true end end