Method: YARD::Templates::Helpers::BaseHelper#format_source

Defined in:
lib/yard/templates/helpers/base_helper.rb

#format_source(value) ⇒ String

Indents and formats source code

Parameters:

  • value (String)

    the input source code

Returns:

  • (String)

    formatted source code



209
210
211
212
213
# File 'lib/yard/templates/helpers/base_helper.rb', line 209

def format_source(value)
  sp = value.split("\n").last[/^(\s+)/, 1]
  num = sp ? sp.size : 0
  value.gsub(/^\s{#{num}}/, '')
end