Class: Solargraph::Pin::Documenting::DocSection

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/pin/documenting.rb

Overview

A documentation formatter that either performs Markdown conversion for text, or applies backticks for code blocks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ DocSection

Returns a new instance of DocSection.

Parameters:

  • code (Boolean)

    True if this section is a code block



41
42
43
44
# File 'lib/solargraph/pin/documenting.rb', line 41

def initialize code
  @plaintext = String.new('')
  @code = code
end

Instance Attribute Details

#plaintextString (readonly)

Returns:

  • (String)


38
39
40
# File 'lib/solargraph/pin/documenting.rb', line 38

def plaintext
  @plaintext
end

Instance Method Details

#code?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/solargraph/pin/documenting.rb', line 46

def code?
  @code
end

#concat(text) ⇒ String

Parameters:

  • text (String)

Returns:

  • (String)


52
53
54
# File 'lib/solargraph/pin/documenting.rb', line 52

def concat text
  @plaintext.concat text
end

#to_sObject



56
57
58
59
# File 'lib/solargraph/pin/documenting.rb', line 56

def to_s
  return to_code if code?
  to_markdown
end