Module: YARD::Templates::Helpers::UMLHelper
- Defined in:
- lib/yard/templates/helpers/uml_helper.rb
Overview
Helpers for UML template format
Instance Method Summary (collapse)
-
- (String) format_path(object)
Formats the path of an object for Graphviz syntax.
-
- (String) h(text)
Encodes text in escaped Graphviz syntax.
-
- (String) tidy(data)
Tidies data by formatting and indenting text.
-
- (String) uml_visibility(object)
Official UML visibility prefix syntax for an object given its visibility.
Instance Method Details
- (String) format_path(object)
Formats the path of an object for Graphviz syntax
19 20 21 |
# File 'lib/yard/templates/helpers/uml_helper.rb', line 19 def format_path(object) object.path.gsub('::', '_') end |
- (String) h(text)
Encodes text in escaped Graphviz syntax
26 27 28 |
# File 'lib/yard/templates/helpers/uml_helper.rb', line 26 def h(text) text.to_s.gsub(/(\W)/, '\\\\\1') end |
- (String) tidy(data)
Tidies data by formatting and indenting text
33 34 35 36 37 38 39 40 41 42 43 |
# 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 |
- (String) uml_visibility(object)
Official UML visibility prefix syntax for an object given its visibility
8 9 10 11 12 13 14 |
# 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 |