Module: YARD::Markdown::RelationshipSectionHelper
- Defined in:
- lib/yard/markdown/relationship_section_helper.rb
Overview
Renders inheritance and mixin relationship summaries.
Instance Method Summary collapse
-
#object_relationships(object) ⇒ String
Returns inheritance and mixin relationships for an object.
-
#render_section_content(content) ⇒ String
Returns section content with the expected trailing spacing.
Instance Method Details
#object_relationships(object) ⇒ String
Returns inheritance and mixin relationships for an object.
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.
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 |