Skip to content
Browse files

Improve inheriting types of overridden cfg/property.

  • Loading branch information...
1 parent bbb2579 commit 112e63412d01c0558ac07b060686e0d12b448262 @nene nene committed
Showing with 37 additions and 14 deletions.
  1. +1 −1 lib/jsduck/inherit_doc.rb
  2. +36 −13 spec/aggregator_inheritdoc_spec.rb
View
2 lib/jsduck/inherit_doc.rb
@@ -34,10 +34,10 @@ def resolve(m, new_cfgs)
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
View
49 spec/aggregator_inheritdoc_spec.rb
@@ -725,34 +725,57 @@ def parse_simple_source(at_tag)
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

0 comments on commit 112e634

Please sign in to comment.
Something went wrong with that request. Please try again.