From f6e1305e01121d72d54b875b764e6422f12f5ba1 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Mon, 16 Jul 2012 17:37:02 -0700 Subject: [PATCH] Consider alternateClassNames when generating @since tags. --- lib/jsduck/old_versions.rb | 9 ++++++--- spec/old_versions_spec.rb | 12 +++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/jsduck/old_versions.rb b/lib/jsduck/old_versions.rb index 4a2d4909..6d950c0f 100644 --- a/lib/jsduck/old_versions.rb +++ b/lib/jsduck/old_versions.rb @@ -55,14 +55,17 @@ module JsDuck # classes/members. def generate_since_tags(versions, relations) relations.each do |cls| - cls[:meta][:since] = available_since(versions, cls[:name]) + cls[:meta][:since] = available_since(versions, cls) end end # Returns name of the version since which the class is available - def available_since(versions, class_name) + def available_since(versions, cls) versions.each do |ver| - return ver[:version] if ver[:classes][class_name] + return ver[:version] if ver[:classes][cls[:name]] + cls[:alternateClassNames].each do |name| + return ver[:version] if ver[:classes][name] + end end end diff --git a/spec/old_versions_spec.rb b/spec/old_versions_spec.rb index 2c332577..28e58070 100644 --- a/spec/old_versions_spec.rb +++ b/spec/old_versions_spec.rb @@ -13,6 +13,7 @@ describe "JsDuck::OldVersions#generate_since_tags" do :version => "2.0", :classes => { "VeryOldClass" => {}, "OldClass" => {}, + "ClassWithOldName" => {}, }, }, { @@ -20,9 +21,10 @@ describe "JsDuck::OldVersions#generate_since_tags" do } ] @relations = [ - {:name => "VeryOldClass", :meta => {}}, - {:name => "OldClass", :meta => {}}, - {:name => "NewClass", :meta => {}}, + {:name => "VeryOldClass", :meta => {}, :alternateClassNames => []}, + {:name => "OldClass", :meta => {}, :alternateClassNames => []}, + {:name => "NewClass", :meta => {}, :alternateClassNames => []}, + {:name => "ClassWithNewName", :meta => {}, :alternateClassNames => ["ClassWithOldName"]}, ] JsDuck::OldVersions.generate_since_tags(@versions, @relations) end @@ -39,4 +41,8 @@ describe "JsDuck::OldVersions#generate_since_tags" do @relations[2][:meta][:since].should == "3.0" end + it "adds @since 2.0 to ClassWithNewName" do + @relations[3][:meta][:since].should == "2.0" + end + end -- GitLab