templates/default/module/setup.rb in yard-0.7.5 vs templates/default/module/setup.rb in yard-0.8.0

- old
+ new

@@ -1,14 +1,14 @@ include Helpers::ModuleHelper def init - sections :header, :box_info, :pre_docstring, T('docstring'), :children, - :constant_summary, [T('docstring')], :inherited_constants, + sections :header, :box_info, :pre_docstring, T('docstring'), :children, + :constant_summary, [T('docstring')], :inherited_constants, :attribute_summary, [:item_summary], :inherited_attributes, :method_summary, [:item_summary], :inherited_methods, :methodmissing, [T('method_details')], - :attribute_details, [T('method_details')], + :attribute_details, [T('method_details')], :method_details_list, [T('method_details')] end def pre_docstring return if object.docstring.blank? @@ -33,11 +33,14 @@ end def method_listing(include_specials = true) return @smeths ||= method_listing.reject {|o| special_method?(o) } unless include_specials return @meths if @meths - @meths = object.meths(:inherited => false, :included => false) + @meths = object.meths(:inherited => false, :included => !options.embed_mixins.empty?) + if options.embed_mixins.size > 0 + @meths = @meths.reject {|m| options.embed_mixins_match?(m.namespace) == false } + end @meths = sort_listing(prune_method_listing(@meths)) @meths end def special_method?(meth) @@ -47,16 +50,23 @@ end def attr_listing return @attrs if @attrs @attrs = [] - [:class, :instance].each do |scope| - object.attributes[scope].each do |name, rw| - @attrs << (rw[:read] || rw[:write]) + object.inheritance_tree(true).each do |superclass| + next if superclass.is_a?(CodeObjects::Proxy) + next if options.embed_mixins.size > 0 && + options.embed_mixins_match?(superclass) == false + [:class, :instance].each do |scope| + superclass.attributes[scope].each do |name, rw| + attr = prune_method_listing([rw[:read], rw[:write]].compact, false).first + @attrs << attr if attr + end end + break if options.embed_mixins.empty? end - @attrs = sort_listing(prune_method_listing(@attrs, false)) + @attrs = sort_listing(@attrs) end def constant_listing return @constants if @constants @constants = object.constants(:included => false, :inherited => false) @@ -70,10 +80,11 @@ end def inherited_attr_list(&block) object.inheritance_tree(true)[1..-1].each do |superclass| next if superclass.is_a?(YARD::CodeObjects::Proxy) + next if options.embed_mixins.size > 0 && options.embed_mixins_match?(superclass) != false attribs = superclass.attributes[:instance] attribs = attribs.reject {|name, rw| object.child(:scope => :instance, :name => name) != nil } attribs = attribs.sort_by {|args| args.first.to_s }.map {|n, m| m[:read] || m[:write] } attribs = prune_method_listing(attribs, false) yield superclass, attribs if attribs.size > 0 @@ -81,10 +92,11 @@ end def inherited_constant_list(&block) object.inheritance_tree(true)[1..-1].each do |superclass| next if superclass.is_a?(YARD::CodeObjects::Proxy) + next if options.embed_mixins.size > 0 && options.embed_mixins_match?(superclass) != false consts = superclass.constants(:included => false, :inherited => false) consts = consts.reject {|const| object.child(:type => :constant, :name => const.name) != nil } consts = consts.sort_by {|const| const.name.to_s } consts = run_verifier(consts) yield superclass, consts if consts.size > 0 @@ -100,21 +112,22 @@ end if docstring.summary.empty? && obj.tags(:return).size == 1 && obj.tag(:return).text docstring = Docstring.new(obj.tag(:return).text.gsub(/\A([a-z])/) {|x| x.upcase }.strip) end - + docstring end def docstring_summary(obj) docstring_full(obj).summary end def groups(list, type = "Method") if groups_data = object.groups - others = list.select {|m| !m.group } + list.each {|m| groups_data |= [m.group] if m.group && owner != m.namespace } + others = list.select {|m| !m.group || !groups_data.include?(m.group) } groups_data.each do |name| items = list.select {|m| m.group == name } yield(items, name) unless items.empty? end else @@ -127,11 +140,11 @@ others << meth end end group_data.each {|group, items| yield(items, group) unless items.empty? } end - + scopes(others) {|items, scope| yield(items, "#{scope.to_s.capitalize} #{type} Summary") } end def scopes(list) [:class, :instance].each do |scope| @@ -144,8 +157,8 @@ unless globals.mixed_into globals.mixed_into = {} list = run_verifier Registry.all(:class, :module) list.each {|o| o.mixins.each {|m| (globals.mixed_into[m.path] ||= []) << o } } end - + globals.mixed_into[object.path] || [] end