Module: YARD::Markdown::SectionAssemblyHelper
- Defined in:
- lib/yard/markdown/section_assembly_helper.rb
Overview
Assembles grouped content into ordered Markdown sections.
Instance Method Summary collapse
-
#append_lines(lines, content, separated: true) ⇒ void
Appends non-empty content to a mutable list of lines.
-
#grouped_items(items, group_order) ⇒ Array<Array>
Groups items by their YARD group and orders them for rendering.
-
#render_section_content(content) ⇒ String
Returns section content with the expected trailing spacing.
Instance Method Details
#append_lines(lines, content, separated: true) ⇒ void
This method returns an undefined value.
Appends non-empty content to a mutable list of lines.
38 39 40 41 42 43 |
# File 'lib/yard/markdown/section_assembly_helper.rb', line 38 def append_lines(lines, content, separated: true) return if content.lstrip.empty? lines << "" if separated && !lines.empty? && !lines.last.empty? lines.concat(content.split("\n")) end |
#grouped_items(items, group_order) ⇒ Array<Array>
Groups items by their YARD group and orders them for rendering.
23 24 25 26 27 28 29 30 |
# File 'lib/yard/markdown/section_assembly_helper.rb', line 23 def grouped_items(items, group_order) groups = items.group_by(&:group) names = groups.keys order = Array(group_order) ordered_names = (order & names) + (names.compact - order).sort + ([nil] & names) ordered_names.map { |name| [name, groups.fetch(name)] } end |
#render_section_content(content) ⇒ String
Returns section content with the expected trailing spacing.
11 12 13 14 15 16 |
# File 'lib/yard/markdown/section_assembly_helper.rb', line 11 def render_section_content(content) text = content.to_s.strip return "" if text.empty? "#{text}\n\n" end |