yard-markdown 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,348 @@
1
- module Yard
1
+ # Namespace for YARD extensions used by this gem.
2
+ module YARD
3
+ # Shared helpers for rendering YARD objects as Markdown.
2
4
  module Markdown
3
- VERSION: String
4
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ # Computes anchor ids that match the generated Markdown headings.
6
+ module ArefHelper
7
+ include YARD::Markdown::AnchorComponentHelper
8
+
9
+ # Returns the primary anchor id for a documented object.
10
+ #
11
+ # _@param_ `object` — Object being rendered.
12
+ #
13
+ # _@return_ — Anchor id for the object's heading.
14
+ def aref: (untyped object) -> String
15
+
16
+ # Encodes a value so it can be embedded safely in an HTML anchor id.
17
+ #
18
+ # _@param_ `value` — Raw anchor fragment to encode.
19
+ #
20
+ # _@return_ — Anchor-safe identifier fragment.
21
+ def anchor_component: (Object value) -> String
22
+ end
23
+
24
+ # Builds headings and legacy anchors for rendered object sections.
25
+ module HeadingHelper
26
+ include YARD::Markdown::ArefHelper
27
+
28
+ # Returns the legacy YARD anchor for an object when one exists.
29
+ #
30
+ # _@param_ `object` — Object being rendered.
31
+ #
32
+ # _@return_ — Legacy anchor id, if supported.
33
+ def legacy_aref: (untyped object) -> String?
34
+
35
+ # Returns all anchor tags that should be attached to a heading.
36
+ #
37
+ # _@param_ `object` — Object being rendered.
38
+ #
39
+ # _@return_ — HTML anchor tags for the object.
40
+ def anchor_tags_for: (untyped object) -> ::Array[String]
41
+
42
+ # Appends the generated anchor tags to a Markdown heading.
43
+ #
44
+ # _@param_ `heading` — Heading text to decorate.
45
+ #
46
+ # _@param_ `object` — Object being rendered.
47
+ #
48
+ # _@return_ — Heading text with embedded anchor tags.
49
+ def heading_with_anchors: (String heading, untyped object) -> String
50
+
51
+ # Builds an HTML anchor tag for a generated id.
52
+ #
53
+ # _@param_ `id` — Anchor id value.
54
+ #
55
+ # _@return_ — HTML anchor tag.
56
+ def anchor_tag: (String id) -> String
57
+
58
+ # Returns the primary anchor id for a documented object.
59
+ #
60
+ # _@param_ `object` — Object being rendered.
61
+ #
62
+ # _@return_ — Anchor id for the object's heading.
63
+ def aref: (untyped object) -> String
64
+
65
+ # Encodes a value so it can be embedded safely in an HTML anchor id.
66
+ #
67
+ # _@param_ `value` — Raw anchor fragment to encode.
68
+ #
69
+ # _@return_ — Anchor-safe identifier fragment.
70
+ def anchor_component: (Object value) -> String
71
+ end
72
+
73
+ # Converts YARD docstrings into Markdown-friendly text.
74
+ module DocumentationHelper
75
+ # Returns the rendered documentation text for an object.
76
+ #
77
+ # _@param_ `object` — Object whose docstring is being rendered.
78
+ #
79
+ # _@return_ — Converted documentation text or a fallback message.
80
+ def documented_text: (untyped object) -> String
81
+
82
+ # Converts an RDoc-formatted docstring to Markdown.
83
+ #
84
+ # _@param_ `docstring` — Raw docstring content.
85
+ #
86
+ # _@return_ — Markdown-rendered docstring content.
87
+ def rdoc_to_md: (Object docstring) -> String
88
+ end
89
+
90
+ # Collects and sorts the objects shown on a rendered object page.
91
+ module ObjectListingHelper
92
+ # Returns the constants and class variables defined on an object.
93
+ #
94
+ # _@param_ `object` — Object being rendered.
95
+ #
96
+ # _@return_ — Constants and class variables.
97
+ def constant_listing: (untyped object) -> ::Array[untyped]
98
+
99
+ # Returns the visible public methods defined directly on an object.
100
+ #
101
+ # _@param_ `object` — Object being rendered.
102
+ #
103
+ # _@return_ — Sorted public methods.
104
+ def public_method_list: (untyped object) -> ::Array[untyped]
105
+
106
+ # Returns the public class methods defined directly on an object.
107
+ #
108
+ # _@param_ `object` — Object being rendered.
109
+ #
110
+ # _@return_ — Sorted public class methods.
111
+ def public_class_methods: (untyped object) -> ::Array[untyped]
112
+
113
+ # Returns the public instance methods defined directly on an object.
114
+ #
115
+ # _@param_ `object` — Object being rendered.
116
+ #
117
+ # _@return_ — Sorted public instance methods.
118
+ def public_instance_methods: (untyped object) -> ::Array[untyped]
119
+
120
+ # Returns the visible attribute methods for an object.
121
+ #
122
+ # _@param_ `object` — Object being rendered.
123
+ #
124
+ # _@return_ — Sorted attribute methods.
125
+ def attr_listing: (untyped object) -> ::Array[untyped]
126
+
127
+ # Sorts a listing by scope and case-insensitive name.
128
+ #
129
+ # _@param_ `list` — Objects to sort.
130
+ #
131
+ # _@return_ — Sorted objects.
132
+ def sort_listing: (::Array[untyped] list) -> ::Array[untyped]
133
+
134
+ # Returns whether an object is explicitly hidden with `:nodoc:`.
135
+ #
136
+ # _@param_ `object` — Listed object whose docstring may start with `:nodoc:`.
137
+ #
138
+ # _@return_ — True when the object should be hidden.
139
+ def hidden_object?: (untyped object) -> bool
140
+ end
141
+
142
+ # Formats YARD tags into Markdown list items and fenced examples.
143
+ module TagFormattingHelper
144
+ # Renders all tags for an object as Markdown.
145
+ #
146
+ # _@param_ `object` — Object whose tags are being rendered.
147
+ #
148
+ # _@return_ — Markdown representation of the object's tags.
149
+ def render_tags: (untyped object) -> String
150
+
151
+ # Formats a non-example YARD tag as a Markdown list item body.
152
+ #
153
+ # _@param_ `tag` — Non-example tag being converted into list item text.
154
+ #
155
+ # _@return_ — Markdown representation of the tag.
156
+ def format_tag: (untyped tag) -> String
157
+
158
+ # Normalizes tag type declarations into printable strings.
159
+ #
160
+ # _@param_ `types` — Raw tag types from YARD.
161
+ #
162
+ # _@return_ — Cleaned type strings.
163
+ def normalized_tag_types: ((::Array[Object] | ::Hash[untyped, untyped])? types) -> ::Array[String]
164
+
165
+ # Formats a hash-style tag type entry.
166
+ #
167
+ # _@param_ `name` — Type name to format.
168
+ #
169
+ # _@param_ `value` — Associated type detail.
170
+ #
171
+ # _@return_ — Formatted type entry, or nil when blank.
172
+ def format_hash_tag_type: (String name, Object value) -> String?
173
+ end
174
+
175
+ # Builds anchor-safe identifier fragments from arbitrary values.
176
+ module AnchorComponentHelper
177
+ # Encodes a value so it can be embedded safely in an HTML anchor id.
178
+ #
179
+ # _@param_ `value` — Raw anchor fragment to encode.
180
+ #
181
+ # _@return_ — Anchor-safe identifier fragment.
182
+ def anchor_component: (Object value) -> String
183
+ end
184
+
185
+ # Assembles grouped content into ordered Markdown sections.
186
+ module SectionAssemblyHelper
187
+ # Groups items by their YARD group and orders them for rendering.
188
+ #
189
+ # _@param_ `items` — Renderable objects that expose a YARD group name.
190
+ #
191
+ # _@param_ `group_order` — Preferred ordering for named groups.
192
+ #
193
+ # _@return_ — Ordered pairs of group names and grouped items.
194
+ def grouped_items: (::Array[untyped] items, ::Array[String]? group_order) -> ::Array[::Array[untyped]]
195
+
196
+ # Appends non-empty content to a mutable list of lines.
197
+ #
198
+ # _@param_ `lines` — Destination line buffer.
199
+ #
200
+ # _@param_ `content` — Rendered Markdown block to split into lines.
201
+ #
202
+ # _@param_ `separated` — Whether to insert a blank separator line first.
203
+ def append_lines: (::Array[String] lines, String content, ?separated: bool) -> void
204
+ end
205
+
206
+ # Rewrites generated Markdown links so they point at Markdown output.
207
+ module LinkNormalizationHelper
208
+ # Normalizes generated Markdown before it is written to disk.
209
+ #
210
+ # _@param_ `content` — Markdown content to finalize.
211
+ #
212
+ # _@param_ `current_path` — Output path for the current document.
213
+ #
214
+ # _@return_ — Normalized Markdown content with a trailing newline.
215
+ def finalize_markdown: ((String | ::Array[String]) content, String current_path) -> String
216
+
217
+ # Rewrites local Markdown links relative to the current output path.
218
+ #
219
+ # _@param_ `markdown` — Markdown content to rewrite.
220
+ #
221
+ # _@param_ `current_path` — Output path for the current document.
222
+ #
223
+ # _@return_ — Markdown with local links normalized.
224
+ def normalize_local_links: (String markdown, String current_path) -> String
225
+
226
+ # Resolves a local link path to a YARD registry object when possible.
227
+ #
228
+ # _@param_ `path` — Link target path to resolve.
229
+ #
230
+ # _@param_ `current_dir` — Directory for the current output file.
231
+ #
232
+ # _@return_ — Matched registry object, if any.
233
+ def resolve_registry_object: (String path, Pathname current_dir) -> untyped?
234
+
235
+ # Resolves a local link target to the final relative Markdown path.
236
+ #
237
+ # _@param_ `path` — Link target path to resolve.
238
+ #
239
+ # _@param_ `current_dir` — Directory for the current output file.
240
+ #
241
+ # _@return_ — Relative Markdown path, or nil when unresolved.
242
+ def resolve_local_link_target: (String path, Pathname current_dir) -> String?
243
+
244
+ # Returns whether a path looks like a constant reference.
245
+ #
246
+ # _@param_ `value` — Link target to inspect.
247
+ #
248
+ # _@return_ — True when the path resembles a constant name.
249
+ def constant_reference_path?: (String value) -> bool
250
+
251
+ # Returns whether a path looks like an unresolved bare identifier.
252
+ #
253
+ # _@param_ `path` — Link target to inspect.
254
+ #
255
+ # _@return_ — True when the target should be treated as unresolved.
256
+ def unresolved_identifier_target?: (String path) -> bool
257
+
258
+ # Computes a relative path from the current output directory.
259
+ #
260
+ # _@param_ `current_dir` — Directory for the current output file.
261
+ #
262
+ # _@param_ `target_path` — Output path being linked to.
263
+ #
264
+ # _@return_ — Relative path suitable for a Markdown link.
265
+ def relative_output_path: (Pathname current_dir, (String | Pathname) target_path) -> String
266
+
267
+ # Replaces malformed local Markdown links with inline code.
268
+ #
269
+ # _@param_ `markdown` — Markdown content to normalize.
270
+ #
271
+ # _@return_ — Markdown with malformed local links replaced.
272
+ def normalize_malformed_local_links: (String markdown) -> String
273
+ end
274
+
275
+ # Formats method and attribute names for Markdown headings.
276
+ module MethodPresentationHelper
277
+ # Builds the display heading for a method.
278
+ #
279
+ # _@param_ `method_object` — Method being rendered.
280
+ #
281
+ # _@return_ — Method heading text.
282
+ def formatted_method_heading: (untyped method_object) -> String
283
+
284
+ # Returns the rendered parameter list for a method.
285
+ #
286
+ # _@param_ `method_object` — Method being rendered.
287
+ #
288
+ # _@return_ — Parenthesized method signature.
289
+ def method_signature: (untyped method_object) -> String
290
+
291
+ # Returns the access marker for an attribute.
292
+ #
293
+ # _@param_ `attribute` — Attribute reader or writer.
294
+ #
295
+ # _@return_ — Access mode marker such as `R`, `W`, or `RW`.
296
+ def attribute_access: (untyped attribute) -> String
297
+ end
298
+
299
+ # Renders grouped Markdown sections for constants, attributes, and methods.
300
+ module CollectionRenderingHelper
301
+ # Renders the constants section for an object page.
302
+ #
303
+ # _@param_ `constants` — Constant objects collected for the current page.
304
+ #
305
+ # _@param_ `group_order` — Preferred ordering for group headings.
306
+ #
307
+ # _@return_ — Markdown for the constants section.
308
+ def render_constants: (::Array[untyped] constants, ::Array[String]? group_order) -> String
309
+
310
+ # Renders the attributes section for an object page.
311
+ #
312
+ # _@param_ `attrs` — Attributes to render.
313
+ #
314
+ # _@param_ `group_order` — Preferred ordering for group headings.
315
+ #
316
+ # _@return_ — Markdown for the attributes section.
317
+ def render_attributes: (::Array[untyped] attrs, ::Array[String]? group_order) -> String
318
+
319
+ # Renders a method section for an object page.
320
+ #
321
+ # _@param_ `section_title` — Section title to render.
322
+ #
323
+ # _@param_ `methods` — Method objects collected for the current section.
324
+ #
325
+ # _@param_ `group_order` — Preferred ordering for group headings.
326
+ #
327
+ # _@return_ — Markdown for the method section.
328
+ def render_methods: (String section_title, ::Array[untyped] methods, ::Array[String]? group_order) -> String
329
+ end
330
+
331
+ # Renders inheritance and mixin relationship summaries.
332
+ module RelationshipSectionHelper
333
+ # Returns section content with the expected trailing spacing.
334
+ #
335
+ # _@param_ `content` — Section content to render.
336
+ #
337
+ # _@return_ — Section content followed by blank-line spacing.
338
+ def render_section_content: (Object content) -> String
339
+
340
+ # Returns inheritance and mixin relationships for an object.
341
+ #
342
+ # _@param_ `object` — Object being rendered.
343
+ #
344
+ # _@return_ — Markdown summary of the object's relationships.
345
+ def object_relationships: (untyped object) -> String
346
+ end
5
347
  end
6
- end
348
+ end
@@ -1,58 +1,68 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # https://github.com/lsegal/yard/blob/2d197a381c5d4cc5c55b2c60fff992b31c986361/docs/CodeObjects.md
4
-
5
- require "erb"
6
- require "csv"
3
+ require 'csv'
7
4
 
8
5
  include Helpers::ModuleHelper
9
6
 
7
+ include YARD::Markdown::ArefHelper
8
+ include YARD::Markdown::ObjectListingHelper
9
+
10
+ # Prepares the markdown serializer and renders each object page.
11
+ #
12
+ # @return [void]
10
13
  def init
11
- options.objects = objects = run_verifier(options.objects)
14
+ options.objects = objects = run_verifier(options.objects).reject { |item| item.name == :root }
12
15
 
13
16
  options.delete(:objects)
14
17
  options.delete(:files)
15
18
 
16
- options.serializer.extension = "md"
17
-
18
- generate_method_list
19
+ options.serializer.extension = 'md'
19
20
 
20
21
  objects.each do |object|
21
- next if object.name == :root
22
-
23
- begin
24
- Templates::Engine.with_serializer(object, options.serializer) { serialize(object) }
25
- rescue => e
26
- path = options.serializer.serialized_path(object)
27
- log.error "Exception occurred while generating '#{path}'"
28
- log.backtrace(e)
29
- end
22
+ Templates::Engine.with_serializer(object, options.serializer) { serialize(object) }
23
+ rescue StandardError => e
24
+ path = options.serializer.serialized_path(object)
25
+ log.error "Exception occurred while generating '#{path}'"
26
+ log.backtrace(e)
30
27
  end
31
28
 
32
29
  serialize_index(objects)
33
30
  end
34
31
 
32
+ # Renders the markdown template for a single namespace object.
33
+ #
34
+ # @param object [YARD::CodeObjects::NamespaceObject] Object whose page will be serialized.
35
+ # @return [String] Rendered markdown for the object.
36
+ def serialize(object)
37
+ T('module').run(options.merge(object: object))
38
+ end
39
+
40
+ # Writes the CSV search index for all rendered objects.
41
+ #
42
+ # @param objects [Array<YARD::CodeObjects::NamespaceObject>] Verified objects included in the generated documentation.
43
+ # @return [void]
35
44
  def serialize_index(objects)
36
45
  filepath = "#{options.serializer.basepath}/index.csv"
37
46
 
38
- CSV.open(filepath, "wb") do |csv|
47
+ CSV.open(filepath, 'wb') do |csv|
39
48
  csv << %w[name type path]
40
49
 
41
50
  objects.each do |object|
42
51
  next if object.name == :root
43
52
 
44
53
  if object.type == :class
45
- csv << [object.path, "Class", options.serializer.serialized_path(object)]
54
+ csv << [object.path, 'Class', options.serializer.serialized_path(object)]
46
55
  elsif object.type == :module
47
- csv << [object.path, "Module", options.serializer.serialized_path(object)]
56
+ csv << [object.path, 'Module', options.serializer.serialized_path(object)]
48
57
  end
49
58
 
50
- if constant_listing.size.positive?
51
- constant_listing.each do |cnst|
59
+ constants = constant_listing(object)
60
+ if constants.size.positive?
61
+ constants.each do |cnst|
52
62
  csv << [
53
63
  "#{object.path}.#{cnst.name(false)}",
54
- "Constant",
55
- (options.serializer.serialized_path(object) + "#" + aref(cnst)),
64
+ 'Constant',
65
+ (options.serializer.serialized_path(object) + '#' + aref(cnst))
56
66
  ]
57
67
  end
58
68
  end
@@ -61,8 +71,8 @@ def serialize_index(objects)
61
71
  insmeths.each do |item|
62
72
  csv << [
63
73
  "#{object.path}.#{item.name(false)}",
64
- "Method",
65
- options.serializer.serialized_path(object) + "#" + aref(item),
74
+ 'Method',
75
+ options.serializer.serialized_path(object) + '#' + aref(item)
66
76
  ]
67
77
  end
68
78
  end
@@ -71,206 +81,21 @@ def serialize_index(objects)
71
81
  pubmeths.each do |item|
72
82
  csv << [
73
83
  "#{object.path}.#{item.name(false)}",
74
- "Method",
75
- options.serializer.serialized_path(object) + "#" + aref(item),
84
+ 'Method',
85
+ options.serializer.serialized_path(object) + '#' + aref(item)
76
86
  ]
77
87
  end
78
88
  end
79
89
 
80
- if (attrs = attr_listing(object)).size > 0
81
- attrs.each do |item|
82
- csv << [
83
- item.name(false),
84
- "Attribute",
85
- options.serializer.serialized_path(object) + "#" + aref(item),
86
- ]
87
- end
88
- end
89
- end
90
- end
91
- end
92
-
93
- # @param object [YARD::CodeObjects::Base]
94
- # @return [String] markdown formatted string
95
- #
96
- # @todo Extract template out of setup.rb class.
97
- def serialize(object)
98
- template =
99
- ERB.new(
100
- '# <%= format_object_title object %>
101
- <% if CodeObjects::ClassObject === object && object.superclass %>
102
- **Inherits:** <%= object.superclass %>
103
- <% end %><% [[:class, "Extended by"], [:instance, "Includes"]].each do |scope, name| %>
104
- <% if (mix = run_verifier(object.mixins(scope))).size > 0 %>
105
- **<%= name %>:** <%= mix.sort_by {|o| o.path }.join(", ") %>
106
- <% end %><% end %>
107
-
108
- <%= rdoc_to_md object.docstring %>
109
-
110
- <%= render_tags object %>
111
-
112
- <% if (pubmeths = public_class_methods(object)).size > 0 %>
113
- # Class Methods
114
- <% pubmeths.each do |item| %>
115
- ## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join(" ") }.join(", ") %>) [](#<%=aref(item)%>)
116
- <%= rdoc_to_md item.docstring %>
117
- <%= render_tags item %>
118
- <% end %><% end %>
119
- <% if (attrs = attr_listing(object)).size > 0 %>
120
- # Attributes
121
- <% attrs.each do |item|%>
122
- ## <%= item.name %><%= item.reader? ? "[RW]" : "[R]" %> [](#<%=aref(item)%>)
123
- <%= rdoc_to_md item.docstring %>
124
-
125
- <%= render_tags item %>
126
- <% end %><% end %>
127
-
128
- <% if (insmeths = public_instance_methods(object)).size > 0 %>
129
- # Instance Methods
130
- <% insmeths.each do |item| %>
131
- ## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join("") }.join(", ")%>) [](#<%=aref(item)%>)
132
- <%= rdoc_to_md item.docstring %>
133
-
134
- <%= render_tags item %>
135
- <% end %><% end %>',
136
- trim_mode: "<>",
137
- )
138
-
139
- template.result(binding)
140
- end
141
-
142
- require "rdoc"
143
-
144
- ##
145
- # Converts rdoc to markdown.
146
- #
147
- # I didn't found a way to detect yard/rdoc docstrings, so we're running docstrings through rdoc to markdown converter in all cases. If it's yard docstring, it doesn't seem to have any negative effect on end results. But absense of bugs, doesn't mean that there are no issues.
148
- #
149
- # @param docstring [String, YARD::Docstring]
150
- # @return [String] markdown formatted string
151
- def rdoc_to_md(docstring)
152
- RDoc::Markup::ToMarkdown.new.convert(docstring)
153
- end
154
-
155
- ##
156
- # Formats yard tags belonging to a object.
157
- #
158
- # This is mostly a feature of yard and rdoc doesn't have any of that. Rdoc supports ":nodoc:" and other tags. Yard claims to have full support for rdoc, doesn't really handle tags like ":nodoc:" or anything else from rdoc.
159
- #
160
- # There is an attempt to handle @example tag differently, we surround it with a code block.
161
- #
162
- # @see https://rubydoc.info/gems/yard/file/docs/TagsArch.md
163
- #
164
- # @param object [YARD::CodeObjects::Base]
165
- # @return [String] markdown formatted string of Tags
166
-
167
- def render_tags(object)
168
- result = String.new("")
169
- object.tags.each do |tag|
170
- result << if !(tag.tag_name == "example")
171
- "**@#{tag.tag_name}** [#{tag.types&.join(', ')}] #{tag.text}\n\n"
172
- else
173
- ""
174
- end
175
- end
176
-
177
- object.tags.each do |tag|
178
- result << if (tag.tag_name == "example")
179
- "\n**@#{tag.tag_name}**\n```ruby\n#{tag.text}\n```"
180
- else
181
- ""
182
- end
183
- end
184
-
185
- result
186
- end
187
-
188
- def aref(object)
189
- if object.type == :constant
190
- "constant-#{object.name(false)}"
191
- elsif !object.attr_info.nil?
192
- "attribute-#{object.scope[0]}-#{object.name(false)}"
193
- else
194
- "#{object.type}-#{object.scope[0]}-#{object.name(false)}"
195
- end
196
- end
197
-
198
- def constant_listing
199
- return @constants if defined?(@constants) && @constants
200
-
201
- @constants = object.constants(included: false, inherited: false)
202
- @constants += object.cvars
203
- @constants
204
- end
90
+ next unless (attrs = attr_listing(object)).size > 0
205
91
 
206
- def public_method_list(object)
207
- prune_method_listing(
208
- object.meths(inherited: false, visibility: [:public]),
209
- included: false,
210
- ).sort_by { |m| m.name.to_s }
211
- end
212
-
213
- def public_class_methods(object)
214
- public_method_list(object).select { |o| o.scope == :class }
215
- end
216
-
217
- def public_instance_methods(object)
218
- public_method_list(object).select { |o| o.scope == :instance }
219
- end
220
-
221
- def attr_listing(object)
222
- @attrs = []
223
- object
224
- .inheritance_tree(true)
225
- .each do |superclass|
226
- next if superclass.is_a?(CodeObjects::Proxy)
227
- next if !options.embed_mixins.empty? && !options.embed_mixins_match?(superclass)
228
- %i[class instance].each do |scope|
229
- superclass.attributes[scope].each do |_name, rw|
230
- attr = prune_method_listing([rw[:read], rw[:write]].compact, false).first
231
- @attrs << attr if attr
232
- end
92
+ attrs.each do |item|
93
+ csv << [
94
+ "#{object.path}.#{item.name(false)}",
95
+ 'Attribute',
96
+ options.serializer.serialized_path(object) + '#' + aref(item)
97
+ ]
233
98
  end
234
- break if options.embed_mixins.empty?
235
99
  end
236
- sort_listing @attrs
237
- end
238
-
239
- def generate_method_list
240
- @items = prune_method_listing(Registry.all(:method), false)
241
- @items = @items.reject { |m| m.name.to_s =~ /=$/ && m.is_attribute? }
242
- @items = @items.sort_by { |m| m.name.to_s }
243
-
244
- # @list_title = "Method List"
245
- # @list_type = "method"
246
- # generate_list_contents
247
- # binding.irb
248
- end
249
-
250
- def sort_listing(list)
251
- list.sort_by { |o| [o.scope.to_s, o.name.to_s.downcase] }
252
- end
253
-
254
- def groups(list, type = "Method")
255
- groups_data = object.groups
256
- if groups_data
257
- list.each { |m| groups_data |= [m.group] if m.group && owner != m.namespace }
258
- others = list.select { |m| !m.group || !groups_data.include?(m.group) }
259
- groups_data.each do |name|
260
- items = list.select { |m| m.group == name }
261
- yield(items, name) unless items.empty?
262
- end
263
- else
264
- others = []
265
- group_data = {}
266
- list.each { |itm| itm.group ? (group_data[itm.group] ||= []) << itm : others << itm }
267
- group_data.each { |group, items| yield(items, group) unless items.empty? }
268
- end
269
-
270
- return if others.empty?
271
- if others.first.respond_to?(:scope)
272
- scopes(others) { |items, scope| yield(items, "#{scope.to_s.capitalize} #{type}") }
273
- else
274
- yield(others, type)
275
100
  end
276
101
  end