Module: YARD::Markdown::RelationshipSectionHelper

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

Overview

Renders inheritance and mixin relationship summaries.

Instance Method Summary collapse

Instance Method Details

#object_relationships(object) ⇒ String

Returns inheritance and mixin relationships for an object.

Parameters:

  • object (YARD::CodeObjects::NamespaceObject)

    Object being rendered.

Returns:

  • (String)

    Markdown summary of the object’s relationships.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/yard/markdown/relationship_section_helper.rb', line 22

def object_relationships(object)
  lines = []

  lines << "**Inherits:** `#{object.superclass}`" if object.instance_of?(CodeObjects::ClassObject)

  [[:class, 'Extended by'], [:instance, 'Includes']].each do |scope, label|
    mixins = run_verifier(object.mixins(scope)).sort_by { |item| item.path }
    next if mixins.empty?

    lines << "**#{label}:** #{mixins.map { |mixin| "`#{mixin.path}`" }.join(', ')}"
  end

  lines.join("\n")
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/relationship_section_helper.rb', line 11

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

  "#{text}\n\n"
end