Loading lib/jsduck/ast.rb +3 −2 Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ module JsDuck cls[:aliases] = make_string_list(cfg["alias"]) cls[:aliases] += make_string_list(cfg["xtype"]).map {|xtype| "widget."+xtype } cls[:members] = {} cls[:members][:cfg] = make_config(cfg["config"]) cls[:members][:cfg] = make_configs(cfg["config"]) end end Loading Loading @@ -232,7 +232,7 @@ module JsDuck cfg_value && to_value(cfg_value) == true end def make_config(ast) def make_configs(ast) return nil unless ast && ast["type"] == "ObjectExpression" configs = [] Loading @@ -245,6 +245,7 @@ module JsDuck if docset docset[:code] = cfg else cfg[:inheritdoc] = {:no_warnings => true} configs << cfg end end Loading lib/jsduck/inherit_doc.rb +8 −2 Original line number Diff line number Diff line Loading @@ -53,7 +53,10 @@ module JsDuck mixins = @relations[m[:owner]].mixins # Warn when no parent or mixins at all return warn("parent class not found", m) unless parent_cls || mixins.length > 0 if !parent_cls && mixins.length == 0 warn("parent class not found", m) unless m[:no_warnings] return m end # First check for the member in all mixins, because members # from mixins override those from parent class. Looking first Loading @@ -69,7 +72,10 @@ module JsDuck end # Only when both parent and mixins fail, throw warning return warn("parent member not found", m) unless parent if !parent warn("parent member not found", m) unless m[:no_warnings] return m end end return parent[:inheritdoc] ? find_parent(parent) : parent Loading lib/jsduck/merger.rb +3 −3 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ module JsDuck :properties => detect_subproperties(docs, :cfg), :accessor => !!doc_map[:accessor], :evented => !!doc_map[:evented], }, doc_map) }, doc_map, code) end def create_property(docs, code) Loading Loading @@ -189,10 +189,10 @@ module JsDuck end # Detects properties common for each doc-object and adds them def add_shared(hash, doc_map) def add_shared(hash, doc_map, code={}) hash.merge!({ :inheritable => !!doc_map[:inheritable], :inheritdoc => doc_map[:inheritdoc] ? doc_map[:inheritdoc].first : nil, :inheritdoc => doc_map[:inheritdoc] ? doc_map[:inheritdoc].first : code[:inheritdoc], :meta => detect_meta(doc_map), }) # copy :private also to main hash Loading spec/aggregator_cfg_spec.rb +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,10 @@ describe JsDuck::Aggregator do it "finds two configs" do cfg.length.should == 2 end it "sets :inheritdoc flag on config" do cfg[0][:inheritdoc].should == {:no_warnings => true} end end describe "detecting Ext.define() with commented config" do Loading spec/aggregator_inheritdoc_spec.rb +28 −0 Original line number Diff line number Diff line Loading @@ -525,5 +525,33 @@ describe JsDuck::Aggregator do end end describe "autoinherit with config:{}" do before do @docs = parse(<<-EOF) /** */ Ext.define("Parent", { config: { /** * My config. */ foo: 5 } }); /** */ Ext.define("Child", { extend: "Parent", config: { foo: 10 } }); EOF @cls = @docs["Child"] end it "inherits docs from parent" do @cls[:members][:cfg][0][:doc].should == "My config." end end end Loading
lib/jsduck/ast.rb +3 −2 Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ module JsDuck cls[:aliases] = make_string_list(cfg["alias"]) cls[:aliases] += make_string_list(cfg["xtype"]).map {|xtype| "widget."+xtype } cls[:members] = {} cls[:members][:cfg] = make_config(cfg["config"]) cls[:members][:cfg] = make_configs(cfg["config"]) end end Loading Loading @@ -232,7 +232,7 @@ module JsDuck cfg_value && to_value(cfg_value) == true end def make_config(ast) def make_configs(ast) return nil unless ast && ast["type"] == "ObjectExpression" configs = [] Loading @@ -245,6 +245,7 @@ module JsDuck if docset docset[:code] = cfg else cfg[:inheritdoc] = {:no_warnings => true} configs << cfg end end Loading
lib/jsduck/inherit_doc.rb +8 −2 Original line number Diff line number Diff line Loading @@ -53,7 +53,10 @@ module JsDuck mixins = @relations[m[:owner]].mixins # Warn when no parent or mixins at all return warn("parent class not found", m) unless parent_cls || mixins.length > 0 if !parent_cls && mixins.length == 0 warn("parent class not found", m) unless m[:no_warnings] return m end # First check for the member in all mixins, because members # from mixins override those from parent class. Looking first Loading @@ -69,7 +72,10 @@ module JsDuck end # Only when both parent and mixins fail, throw warning return warn("parent member not found", m) unless parent if !parent warn("parent member not found", m) unless m[:no_warnings] return m end end return parent[:inheritdoc] ? find_parent(parent) : parent Loading
lib/jsduck/merger.rb +3 −3 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ module JsDuck :properties => detect_subproperties(docs, :cfg), :accessor => !!doc_map[:accessor], :evented => !!doc_map[:evented], }, doc_map) }, doc_map, code) end def create_property(docs, code) Loading Loading @@ -189,10 +189,10 @@ module JsDuck end # Detects properties common for each doc-object and adds them def add_shared(hash, doc_map) def add_shared(hash, doc_map, code={}) hash.merge!({ :inheritable => !!doc_map[:inheritable], :inheritdoc => doc_map[:inheritdoc] ? doc_map[:inheritdoc].first : nil, :inheritdoc => doc_map[:inheritdoc] ? doc_map[:inheritdoc].first : code[:inheritdoc], :meta => detect_meta(doc_map), }) # copy :private also to main hash Loading
spec/aggregator_cfg_spec.rb +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,10 @@ describe JsDuck::Aggregator do it "finds two configs" do cfg.length.should == 2 end it "sets :inheritdoc flag on config" do cfg[0][:inheritdoc].should == {:no_warnings => true} end end describe "detecting Ext.define() with commented config" do Loading
spec/aggregator_inheritdoc_spec.rb +28 −0 Original line number Diff line number Diff line Loading @@ -525,5 +525,33 @@ describe JsDuck::Aggregator do end end describe "autoinherit with config:{}" do before do @docs = parse(<<-EOF) /** */ Ext.define("Parent", { config: { /** * My config. */ foo: 5 } }); /** */ Ext.define("Child", { extend: "Parent", config: { foo: 10 } }); EOF @cls = @docs["Child"] end it "inherits docs from parent" do @cls[:members][:cfg][0][:doc].should == "My config." end end end