Module: YARD::Markdown::DocumentationHelper

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

Overview

Converts YARD docstrings into Markdown-friendly text.

Instance Method Summary collapse

Instance Method Details

#documented_text(object) ⇒ String

Returns the rendered documentation text for an object.

Parameters:

  • object (YARD::CodeObjects::Base)

    Object whose docstring is being rendered.

Returns:

  • (String)

    Converted documentation text or a fallback message.



13
14
15
16
17
18
19
# File 'lib/yard/markdown/documentation_helper.rb', line 13

def documented_text(object)
  text = rdoc_to_md(object.docstring)
  return text unless text.empty?
  return '' unless object.tags.empty?

  'Not documented.'
end

#rdoc_to_md(docstring) ⇒ String

Converts an RDoc-formatted docstring to Markdown.

Parameters:

  • docstring (Object)

    Raw docstring content.

Returns:

  • (String)

    Markdown-rendered docstring content.



25
26
27
# File 'lib/yard/markdown/documentation_helper.rb', line 25

def rdoc_to_md(docstring)
  RDoc::Markup::ToMarkdown.new.convert(docstring).rstrip
end