Module: YARD::Templates::Helpers::BaseHelper

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

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

- (Object) object

Returns the value of attribute object



3
4
5
# File 'lib/yard/templates/helpers/base_helper.rb', line 3

def object
  @object
end

- (Object) serializer

Returns the value of attribute serializer



3
4
5
# File 'lib/yard/templates/helpers/base_helper.rb', line 3

def serializer
  @serializer
end

Instance Method Details

- (Object) format_object_title(object)



55
56
57
58
59
60
61
62
# File 'lib/yard/templates/helpers/base_helper.rb', line 55

def format_object_title(object)
  case object
  when YARD::CodeObjects::RootObject
    "Top Level Namespace"
  else
    format_object_type(object) + ": " + object.path
  end
end

- (Object) format_object_type(object)



46
47
48
49
50
51
52
53
# File 'lib/yard/templates/helpers/base_helper.rb', line 46

def format_object_type(object)
  case object
  when YARD::CodeObjects::ClassObject
    object.is_exception? ? "Exception" : "Class"
  else
    object.type.to_s.capitalize
  end
end

- (Object) format_source(value)



64
65
66
67
68
# File 'lib/yard/templates/helpers/base_helper.rb', line 64

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

- (Object) format_types(list, brackets = true)



42
43
44
# File 'lib/yard/templates/helpers/base_helper.rb', line 42

def format_types(list, brackets = true)
  list.nil? || list.empty? ? "" : (brackets ? "(#{list.join(", ")})" : list.join(", "))
end

- (Object) h(text)

This is used a lot by the HtmlHelper and there should be some helper to “clean up” text for whatever, this is it.



12
13
14
# File 'lib/yard/templates/helpers/base_helper.rb', line 12

def h(text)
  text
end


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/yard/templates/helpers/base_helper.rb', line 25

def link_object(object, title = nil)
  return title if title
  
  case object
  when YARD::CodeObjects::Base, YARD::CodeObjects::Proxy
    object.path
  when String, Symbol
    P(object).path
  else
    object
  end
end


38
39
40
# File 'lib/yard/templates/helpers/base_helper.rb', line 38

def link_url(url)
  url
end

- (Object) linkify(*args)



16
17
18
19
20
21
22
23
# File 'lib/yard/templates/helpers/base_helper.rb', line 16

def linkify(*args) 
  # The :// character sequence exists in no valid object path but just about every URL scheme.
  if args.first.is_a?(String) && args.first.include?("://")
    link_url(*args)
  else
    link_object(*args)
  end
end

- (Object) run_verifier(list)



5
6
7
8
# File 'lib/yard/templates/helpers/base_helper.rb', line 5

def run_verifier(list)
  return list unless options[:verifier]
  list.reject {|item| options[:verifier].call(item).is_a?(FalseClass) }
end