Module: YARD::Markdown::DocumentationHelper
- Defined in:
- lib/yard/markdown/documentation_helper.rb
Overview
Converts YARD docstrings into Markdown-friendly text.
Instance Method Summary collapse
-
#documented_text(object) ⇒ String
Returns the rendered documentation text for an object.
-
#rdoc_to_md(docstring) ⇒ String
Converts an RDoc-formatted docstring to Markdown.
Instance Method Details
#documented_text(object) ⇒ String
Returns the rendered documentation text for an object.
13 14 15 16 17 18 |
# File 'lib/yard/markdown/documentation_helper.rb', line 13 def documented_text(object) text = rdoc_to_md(object.docstring) return text unless text.empty? object..empty? ? "Not documented." : "" end |
#rdoc_to_md(docstring) ⇒ String
Converts an RDoc-formatted docstring to Markdown.
24 25 26 27 28 29 30 |
# File 'lib/yard/markdown/documentation_helper.rb', line 24 def rdoc_to_md(docstring) fenced_code_blocks = [] placeholder = "YARD_MARKDOWN_FENCED_CODE_BLOCK_%d" content = extract_fenced_code_blocks(docstring, fenced_code_blocks, placeholder) markdown = RDoc::Markup::ToMarkdown.new.convert(content).rstrip restore_fenced_code_blocks(markdown, fenced_code_blocks, placeholder) end |