1 lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../../lib'))
2 $LOAD_PATH.unshift(lib_dir)
4 require 'yard-google-code'
6 include Helpers::ModuleHelper
9 sections :header, :box_info, :pre_docstring, T('docstring'), :children,
10 :constant_summary, [T('docstring')], :inherited_constants,
12 :methodmissing, [T('method_details')],
13 :attribute_details, [T('method_details')],
14 :method_details_list, [T('method_details')]
18 return if object.docstring.blank?
23 @inner = [[:modules, []], [:classes, []]]
24 object.children.each do |child|
25 @inner[0][1] << child if child.type == :module
26 @inner[1][1] << child if child.type == :class
28 @inner.map! {|v| [v[0], run_verifier(v[1].sort_by {|o| o.name.to_s })] }
29 return if (@inner[0][1].size + @inner[1][1].size) == 0
34 mms = object.meths(:inherited => true, :included => true)
35 return unless @mm = mms.find {|o| o.name == :method_missing && o.scope == :instance }
39 def method_listing(include_specials = true)
40 return @smeths ||= method_listing.reject {|o| special_method?(o) } unless include_specials
41 return @meths if @meths
42 @meths = object.meths(:inherited => false, :included => false)
43 @meths = sort_listing(prune_method_listing(@meths))
47 def special_method?(meth)
48 return true if meth.name(true) == '#method_missing'
49 return true if meth.constructor?
54 return @attrs if @attrs
56 [:class, :instance].each do |scope|
57 object.attributes[scope].each do |name, rw|
58 @attrs << (rw[:read] || rw[:write])
61 @attrs = sort_listing(prune_method_listing(@attrs, false))
65 return @constants if @constants
66 @constants = object.constants(:included => false, :inherited => false)
67 @constants += object.cvars
68 @constants = run_verifier(@constants)
72 def sort_listing(list)
73 list.sort_by {|o| [o.scope.to_s, o.name.to_s.downcase] }
76 def docstring_full(obj)
78 if obj.tags(:overload).size == 1 && obj.docstring.empty?
79 docstring = obj.tag(:overload).docstring
81 docstring = obj.docstring
84 if docstring.summary.empty? && obj.tags(:return).size == 1 && obj.tag(:return).text
85 docstring = Docstring.new(obj.tag(:return).text.gsub(/\A([a-z])/) {|x| x.upcase }.strip)
91 def docstring_summary(obj)
92 docstring_full(obj).summary
95 def groups(list, type = "Method")
96 if groups_data = object.groups
97 others = list.select {|m| !m.group }
98 groups_data.each do |name|
99 items = list.select {|m| m.group == name }
100 yield(items, name) unless items.empty?
107 (group_data[meth.group] ||= []) << meth
112 group_data.each {|group, items| yield(items, group) unless items.empty? }
115 scopes(others) {|items, scope| yield(items, "#{scope.to_s.capitalize} #{type} Summary") }
119 [:class, :instance].each do |scope|
120 items = list.select {|m| m.scope == scope }
121 yield(items, scope) unless items.empty?
125 def mixed_into(object)
126 unless globals.mixed_into
127 globals.mixed_into = {}
128 list = run_verifier Registry.all(:class, :module)
129 list.each {|o| o.mixins.each {|m| (globals.mixed_into[m.path] ||= []) << o } }
132 globals.mixed_into[object.path] || []