Loading lib/jsduck/class.rb +8 −2 Original line number Diff line number Diff line Loading @@ -239,7 +239,11 @@ module JsDuck # # Optionally one can also specify type name to differenciate # between different types of members. def get_members(name, type_name=nil, static=false) # # Finally static flag can be specified. True to look only at # static members, false to look at instance members, and nil to # look at both. def get_members(name, type_name=nil, static=nil) # build hash of all members unless @members_map @members_map = {} Loading @@ -254,7 +258,9 @@ module JsDuck ms = @members_map[name] || [] ms = ms.find_all {|m| m[:tagname] == type_name } if type_name ms = ms.find_all {|m| m[:meta][:static] } if static # static = true | false | nil ms = ms.find_all {|m| m[:meta][:static] } if static == true ms = ms.find_all {|m| !m[:meta][:static] } if static == false return ms end Loading lib/jsduck/doc_formatter.rb +5 −5 Original line number Diff line number Diff line Loading @@ -133,12 +133,12 @@ module JsDuck text = $2 if target =~ /^(.*)#(static-)?(?:(cfg|property|method|event|css_var|css_mixin)-)?(.*)$/ cls = $1.empty? ? @class_context : $1 static = !!$2 static = $2 ? true : nil type = $3 ? $3.intern : nil member = $4 else cls = target static = false static = nil type = false member = false end Loading Loading @@ -257,7 +257,7 @@ module JsDuck end # applies the link template def link(cls, member, anchor_text, type=nil, static=false) def link(cls, member, anchor_text, type=nil, static=nil) # Use the canonical class name for link (not some alternateClassName) cls = @relations[cls].full_name # prepend type name to member name Loading @@ -281,7 +281,7 @@ module JsDuck end end def get_matching_member(cls, member, type=nil, static=false) def get_matching_member(cls, member, type=nil, static=nil) ms = get_members(cls, member, type, static).find_all {|m| !m[:private] } if ms.length > 1 instance_ms = ms.find_all {|m| !m[:meta][:static] } Loading @@ -291,7 +291,7 @@ module JsDuck end end def get_members(cls, member, type=nil, static=false) def get_members(cls, member, type=nil, static=nil) @relations[cls] ? @relations[cls].get_members(member, type, static) : [] end Loading lib/jsduck/inherit_doc.rb +21 −14 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ module JsDuck end end #pp parent[:doc] return parent[:inheritdoc] ? find_parent(parent) : parent end Loading @@ -126,11 +127,12 @@ module JsDuck tagname = inherit[:type] || m[:tagname] static = inherit[:static] || m[:meta][:static] if m[:autodetected] # Auto-detected properties can override either a property or a # config. So look for both types. if m[:autodetected] && tagname == :property cfg = cls.get_members(name, :cfg, static)[0] prop = cls.get_members(name, :property, static)[0] if tagname == :property cfg = cls.get_members(name, :cfg, static || false)[0] prop = cls.get_members(name, :property, static || false)[0] if cfg && prop prop Loading @@ -142,6 +144,11 @@ module JsDuck nil end else # Unless the auto-detected member is detected as static, # look only at instance members. cls.get_members(name, tagname, static || false)[0] end else cls.get_members(name, tagname, static)[0] end Loading spec/aggregator_inheritdoc_spec.rb +66 −0 Original line number Diff line number Diff line Loading @@ -697,5 +697,71 @@ describe JsDuck::Aggregator do @cfg[:meta][:deprecated][:version].should == "4.0" end end describe "instance members autoinherit with parent containing statics" do before do @docs = parse(<<-EOF) /** */ Ext.define("Parent", { inheritableStatics: { /** My method. */ foo: function() {}, /** My property. */ bar: 10 } }); /** */ Ext.define("Child", { extend: "Parent", foo: function(){}, bar: 11 }); EOF @cls = @docs["Child"] @cfg = @cls[:members][:property][0] end it "doesn't inherit from parent static method" do @cls[:members][:method][0][:doc].should_not == "My method." end it "doesn't inherit from parent static property" do @cls[:members][:property][0][:doc].should_not == "My property." end end describe "static members autoinherit with parent containing statics" do before do @docs = parse(<<-EOF) /** */ Ext.define("Parent", { inheritableStatics: { /** My method. */ foo: function() {}, /** My property. */ bar: 10 } }); /** */ Ext.define("Child", { extend: "Parent", inheritableStatics: { foo: function(){}, bar: 11 } }); EOF @cls = @docs["Child"] @cfg = @cls[:members][:property][0] end it "inherits from parent static method" do @cls[:statics][:method][0][:doc].should == "My method." end it "inherits from parent static property" do @cls[:statics][:property][0][:doc].should == "My property." end end end Loading
lib/jsduck/class.rb +8 −2 Original line number Diff line number Diff line Loading @@ -239,7 +239,11 @@ module JsDuck # # Optionally one can also specify type name to differenciate # between different types of members. def get_members(name, type_name=nil, static=false) # # Finally static flag can be specified. True to look only at # static members, false to look at instance members, and nil to # look at both. def get_members(name, type_name=nil, static=nil) # build hash of all members unless @members_map @members_map = {} Loading @@ -254,7 +258,9 @@ module JsDuck ms = @members_map[name] || [] ms = ms.find_all {|m| m[:tagname] == type_name } if type_name ms = ms.find_all {|m| m[:meta][:static] } if static # static = true | false | nil ms = ms.find_all {|m| m[:meta][:static] } if static == true ms = ms.find_all {|m| !m[:meta][:static] } if static == false return ms end Loading
lib/jsduck/doc_formatter.rb +5 −5 Original line number Diff line number Diff line Loading @@ -133,12 +133,12 @@ module JsDuck text = $2 if target =~ /^(.*)#(static-)?(?:(cfg|property|method|event|css_var|css_mixin)-)?(.*)$/ cls = $1.empty? ? @class_context : $1 static = !!$2 static = $2 ? true : nil type = $3 ? $3.intern : nil member = $4 else cls = target static = false static = nil type = false member = false end Loading Loading @@ -257,7 +257,7 @@ module JsDuck end # applies the link template def link(cls, member, anchor_text, type=nil, static=false) def link(cls, member, anchor_text, type=nil, static=nil) # Use the canonical class name for link (not some alternateClassName) cls = @relations[cls].full_name # prepend type name to member name Loading @@ -281,7 +281,7 @@ module JsDuck end end def get_matching_member(cls, member, type=nil, static=false) def get_matching_member(cls, member, type=nil, static=nil) ms = get_members(cls, member, type, static).find_all {|m| !m[:private] } if ms.length > 1 instance_ms = ms.find_all {|m| !m[:meta][:static] } Loading @@ -291,7 +291,7 @@ module JsDuck end end def get_members(cls, member, type=nil, static=false) def get_members(cls, member, type=nil, static=nil) @relations[cls] ? @relations[cls].get_members(member, type, static) : [] end Loading
lib/jsduck/inherit_doc.rb +21 −14 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ module JsDuck end end #pp parent[:doc] return parent[:inheritdoc] ? find_parent(parent) : parent end Loading @@ -126,11 +127,12 @@ module JsDuck tagname = inherit[:type] || m[:tagname] static = inherit[:static] || m[:meta][:static] if m[:autodetected] # Auto-detected properties can override either a property or a # config. So look for both types. if m[:autodetected] && tagname == :property cfg = cls.get_members(name, :cfg, static)[0] prop = cls.get_members(name, :property, static)[0] if tagname == :property cfg = cls.get_members(name, :cfg, static || false)[0] prop = cls.get_members(name, :property, static || false)[0] if cfg && prop prop Loading @@ -142,6 +144,11 @@ module JsDuck nil end else # Unless the auto-detected member is detected as static, # look only at instance members. cls.get_members(name, tagname, static || false)[0] end else cls.get_members(name, tagname, static)[0] end Loading
spec/aggregator_inheritdoc_spec.rb +66 −0 Original line number Diff line number Diff line Loading @@ -697,5 +697,71 @@ describe JsDuck::Aggregator do @cfg[:meta][:deprecated][:version].should == "4.0" end end describe "instance members autoinherit with parent containing statics" do before do @docs = parse(<<-EOF) /** */ Ext.define("Parent", { inheritableStatics: { /** My method. */ foo: function() {}, /** My property. */ bar: 10 } }); /** */ Ext.define("Child", { extend: "Parent", foo: function(){}, bar: 11 }); EOF @cls = @docs["Child"] @cfg = @cls[:members][:property][0] end it "doesn't inherit from parent static method" do @cls[:members][:method][0][:doc].should_not == "My method." end it "doesn't inherit from parent static property" do @cls[:members][:property][0][:doc].should_not == "My property." end end describe "static members autoinherit with parent containing statics" do before do @docs = parse(<<-EOF) /** */ Ext.define("Parent", { inheritableStatics: { /** My method. */ foo: function() {}, /** My property. */ bar: 10 } }); /** */ Ext.define("Child", { extend: "Parent", inheritableStatics: { foo: function(){}, bar: 11 } }); EOF @cls = @docs["Child"] @cfg = @cls[:members][:property][0] end it "inherits from parent static method" do @cls[:statics][:method][0][:doc].should == "My method." end it "inherits from parent static property" do @cls[:statics][:property][0][:doc].should == "My property." end end end