class Solargraph::Pin::Documenting::DocSection
A documentation formatter that either performs Markdown conversion for text, or applies backticks for code blocks.
Attributes
@return [String]
Public Class Methods
Source
# File lib/solargraph/pin/documenting.rb, line 41 def initialize code @plaintext = String.new('') @code = code end
@param code [Boolean] True if this section is a code block
Public Instance Methods
Source
# File lib/solargraph/pin/documenting.rb, line 52 def concat text @plaintext.concat text end
@param text [String] @return [String]
Source
# File lib/solargraph/pin/documenting.rb, line 56 def to_s return to_code if code? to_markdown end
Private Instance Methods
Source
# File lib/solargraph/pin/documenting.rb, line 64 def to_code "\n```ruby\n#{Documenting.normalize_indentation(@plaintext)}#{@plaintext.end_with?("\n") ? '' : "\n"}```\n\n" end
@return [String]
Source
# File lib/solargraph/pin/documenting.rb, line 69 def to_markdown ReverseMarkdown.convert Kramdown::Document.new(@plaintext, input: 'GFM').to_html end
@return [String]