Module: YARD::Markdown::CollectionRenderingHelper
- Defined in:
- lib/yard/markdown/collection_rendering_helper.rb
Overview
Renders grouped Markdown sections for constants, attributes, and methods.
Instance Method Summary collapse
-
#render_attributes(attrs, group_order) ⇒ String
Renders the attributes section for an object page.
-
#render_collection(section_title, items, group_order) ⇒ String
Renders a grouped collection with a caller-provided item label.
-
#render_constants(constants, group_order) ⇒ String
Renders the constants section for an object page.
-
#render_methods(section_title, methods, group_order) ⇒ String
Renders a method section for an object page.
Instance Method Details
#render_attributes(attrs, group_order) ⇒ String
Renders the attributes section for an object page.
21 22 23 |
# File 'lib/yard/markdown/collection_rendering_helper.rb', line 21 def render_attributes(attrs, group_order) render_collection("Attributes", attrs, group_order) { |item| "`#{item.name}` [#{attribute_access(item)}]" } end |
#render_collection(section_title, items, group_order) ⇒ String
Renders a grouped collection with a caller-provided item label.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/yard/markdown/collection_rendering_helper.rb', line 41 def render_collection(section_title, items, group_order) lines = ["## #{section_title}"] groups = grouped_items(items, group_order) uses_groups = groups.any? { |name, _items| !name.nil? } item_heading = uses_groups ? "####" : "###" groups.each do |group_name, group_items| lines << "### #{group_name || "General"}" if uses_groups lines << group_items.map { |item| item_lines = [heading_with_anchors("#{item_heading} #{yield(item)}", item)] append_lines(item_lines, documented_text(item), separated: false) append_lines(item_lines, (item), separated: false) item_lines.join("\n") }.join("\n\n") end lines.join("\n") end |
#render_constants(constants, group_order) ⇒ String
Renders the constants section for an object page.
12 13 14 |
# File 'lib/yard/markdown/collection_rendering_helper.rb', line 12 def render_constants(constants, group_order) render_collection("Constants", constants.sort_by { |item| item.name }, group_order) { |item| "`#{item.name}`" } end |
#render_methods(section_title, methods, group_order) ⇒ String
Renders a method section for an object page.
31 32 33 |
# File 'lib/yard/markdown/collection_rendering_helper.rb', line 31 def render_methods(section_title, methods, group_order) render_collection(section_title, methods, group_order) { |item| "`#{formatted_method_heading(item)}`" } end |