Method: YARD::Templates::Helpers::MethodHelper#format_constant

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

#format_constant(value) ⇒ String

Returns formats source code of a constant value.

Returns:

  • (String)

    formats source code of a constant value



68
69
70
71
72
73
74
# File 'lib/yard/templates/helpers/method_helper.rb', line 68

def format_constant(value)
  # last can return nil, so default to empty string
  sp = value.split("\n").last || ""
  sp = sp[/^(\s+)/, 1]
  num = sp ? sp.size : 0
  html_syntax_highlight value.gsub(/^\s{#{num}}/, '')
end