module YARD::Templates::Helpers::UMLHelper
Helpers for UML template format
Public Instance Methods
format_path(object)
click to toggle source
Formats the path of an object for Graphviz syntax @param [CodeObjects::Base] object an object to format the path of @return [String] the encoded path
# File lib/yard/templates/helpers/uml_helper.rb, line 19 def format_path(object) object.path.gsub('::', '_') end
h(text)
click to toggle source
Encodes text in escaped Graphviz syntax @param [String] text text to encode @return [String] the encoded text
# File lib/yard/templates/helpers/uml_helper.rb, line 26 def h(text) text.to_s.gsub(/(\W)/, '\\\1') end
tidy(data)
click to toggle source
Tidies data by formatting and indenting text @param [String] data pre-formatted text @return [String] tidied text.
# File lib/yard/templates/helpers/uml_helper.rb, line 33 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
uml_visibility(object)
click to toggle source
Official UML visibility prefix syntax for an object given its visibility @param [CodeObjects::Base] object the object to retrieve visibility for @return [String] the UML visibility prefix
# File lib/yard/templates/helpers/uml_helper.rb, line 8 def uml_visibility(object) case object.visibility when :public; '+' when :protected; '#' when :private; '-' end end