Loading lib/jsduck/inherit_doc.rb +1 −1 Original line number Diff line number Diff line Loading @@ -34,10 +34,10 @@ module JsDuck m[:doc] = (m[:doc] + "\n\n" + parent[:doc]).strip m[:params] = parent[:params] if parent[:params] m[:return] = parent[:return] if parent[:return] m[:type] = parent[:type] if parent[:type] if m[:autodetected] m[:meta] = parent[:meta].merge(m[:meta]) m[:type] = parent[:type] if parent[:type] end # remember properties that have changed to configs Loading spec/aggregator_inheritdoc_spec.rb +36 −13 Original line number Diff line number Diff line Loading @@ -725,34 +725,57 @@ describe JsDuck::Aggregator do end end describe "autoinherit of property with type explicitly defined in parent class" do before do @docs = parse(<<-EOF) describe "inheriting cfg/property type" do let(:members) do ms = parse(<<-EOF)["Child"][:members] /** */ Ext.define("Parent", { /** * @property {String/Number} */ foo: 5, bar: 42 foo: 42, /** * @property {String/Number} */ bar: 5, baz: 15, /** * @property {String/Number} * @private */ zap: 7 }); /** */ Ext.define("Child", { extend: "Parent", foo: 10, bar: true /** * @inheritdoc */ foo: "blah", bar: "blah", baz: "blah", zap: "blah" }); EOF @cls = @docs["Child"] @members = @cls[:members] hash = {} ms.each {|p| hash[p[:name]] = p } hash end it "explicit inherit from public parent keeps the type of parent" do members["foo"][:type].should == "String/Number" end it "autoinherit from public parent keeps the type of parent" do members["bar"][:type].should == "String/Number" end it "keeps the type from public parent" do @members[0][:type].should == "String/Number" it "autoinherit from private parent overrides parent type" do members["baz"][:type].should == "String" end it "overrides the type from private parent" do @members[1][:type].should == "Boolean" it "autoinherit from explicitly documented private parent keeps parent type" do members["zap"][:type].should == "String/Number" end end Loading Loading
lib/jsduck/inherit_doc.rb +1 −1 Original line number Diff line number Diff line Loading @@ -34,10 +34,10 @@ module JsDuck m[:doc] = (m[:doc] + "\n\n" + parent[:doc]).strip m[:params] = parent[:params] if parent[:params] m[:return] = parent[:return] if parent[:return] m[:type] = parent[:type] if parent[:type] if m[:autodetected] m[:meta] = parent[:meta].merge(m[:meta]) m[:type] = parent[:type] if parent[:type] end # remember properties that have changed to configs Loading
spec/aggregator_inheritdoc_spec.rb +36 −13 Original line number Diff line number Diff line Loading @@ -725,34 +725,57 @@ describe JsDuck::Aggregator do end end describe "autoinherit of property with type explicitly defined in parent class" do before do @docs = parse(<<-EOF) describe "inheriting cfg/property type" do let(:members) do ms = parse(<<-EOF)["Child"][:members] /** */ Ext.define("Parent", { /** * @property {String/Number} */ foo: 5, bar: 42 foo: 42, /** * @property {String/Number} */ bar: 5, baz: 15, /** * @property {String/Number} * @private */ zap: 7 }); /** */ Ext.define("Child", { extend: "Parent", foo: 10, bar: true /** * @inheritdoc */ foo: "blah", bar: "blah", baz: "blah", zap: "blah" }); EOF @cls = @docs["Child"] @members = @cls[:members] hash = {} ms.each {|p| hash[p[:name]] = p } hash end it "explicit inherit from public parent keeps the type of parent" do members["foo"][:type].should == "String/Number" end it "autoinherit from public parent keeps the type of parent" do members["bar"][:type].should == "String/Number" end it "keeps the type from public parent" do @members[0][:type].should == "String/Number" it "autoinherit from private parent overrides parent type" do members["baz"][:type].should == "String" end it "overrides the type from private parent" do @members[1][:type].should == "Boolean" it "autoinherit from explicitly documented private parent keeps parent type" do members["zap"][:type].should == "String/Number" end end Loading