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, &label) {|item| ... } ⇒ 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}` [#{MethodPresentationHelper.attribute_access(item)}]" } end |
#render_collection(section_title, items, group_order, &label) {|item| ... } ⇒ String
Renders a grouped collection with a caller-provided item label.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/yard/markdown/collection_rendering_helper.rb', line 43 def render_collection(section_title, items, group_order, &label) groups = SectionAssemblyHelper.grouped_items(items, group_order) grouped = groups.any? { |name, _items| name } body = groups.map do |name, group_items| item_heading = grouped ? "####" : "###" item_markdown = group_items.map { |item| render_collection_item(item_heading, item, &label) }.join("\n\n") [("### #{name || "General"}" if grouped), item_markdown].compact end ["## #{section_title}", body].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(&: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| "`#{MethodPresentationHelper.formatted_method_heading(item)}`" } end |