module YARD::Templates::Helpers::UMLHelper

def format_path(object)

Returns:
  • (String) - the encoded path

Parameters:
  • object (CodeObjects::Base) -- an object to format the path of
def format_path(object)
  object.path.gsub('::', '_')
end

def h(text)

Returns:
  • (String) - the encoded text

Parameters:
  • text (String) -- text to encode
def h(text)
  text.to_s.gsub(/(\W)/, '\\\\\1')
end

def tidy(data)

Returns:
  • (String) - tidied text.

Parameters:
  • data (String) -- pre-formatted text
def tidy(data)
  indent = 0
  data.split(/\n/).map do |line|
    line.gsub!(/^\s*/, '')
    next if line.empty?
    indent -= 1 if line =~ /^\s*\}\s*$/
    line = (' ' * (indent * 2)) + line
    indent += 1 if line =~ /\{\s*$/
    line
  end.compact.join("\n") + "\n"
end

def uml_visibility(object)

Returns:
  • (String) - the UML visibility prefix

Parameters:
  • object (CodeObjects::Base) -- the object to retrieve visibility for
def uml_visibility(object)
  case object.visibility
  when :public;    '+'
  when :protected; '#'
  when :private;   '-'
  end
end