Module: YARD::Markdown::SectionAssemblyHelper

Defined in:
lib/yard/markdown/section_assembly_helper.rb

Overview

Assembles grouped content into ordered Markdown sections.

Class Method Summary collapse

Class Method Details

.grouped_items(items, group_order) ⇒ Array<Array>

Groups items by their YARD group and orders them for rendering.

Parameters:

  • items (Array<#group>)

    Renderable objects that expose a YARD group name.

  • group_order (Array<String>, nil)

    Preferred ordering for named groups.

Returns:

  • (Array<Array>)

    Ordered pairs of group names and grouped items.



23
24
25
26
# File 'lib/yard/markdown/section_assembly_helper.rb', line 23

def self.grouped_items(items, group_order)
  groups = items.group_by(&:group)
  ordered_group_names(groups.keys, Array(group_order)).map { |name| [name, groups.fetch(name)] }
end

.render_section_content(content) ⇒ String

Returns section content with the expected trailing spacing.

Parameters:

  • content (Object)

    Section content to render.

Returns:

  • (String)

    Section content followed by blank-line spacing.



11
12
13
14
15
16
# File 'lib/yard/markdown/section_assembly_helper.rb', line 11

def self.render_section_content(content)
  text = content.to_s.strip
  return "" if text.empty?

  "#{text}\n\n"
end