Module: PDoc::Generators::Html::Helpers::CodeHelper

Included in:
DocPage
Defined in:
lib/pdoc/generators/html/helpers.rb

Instance Method Summary collapse

Instance Method Details



154
155
156
157
158
159
160
161
162
# File 'lib/pdoc/generators/html/helpers.rb', line 154

def breadcrumb(obj, options = {})
  options = {:name => :short}.merge(options)
  result = []
  begin
    result << auto_link(obj, options.dup)
    obj = obj.parent
  end until obj.is_a?(Models::Root)
  result.reverse!
end

#method_synopsis(object) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/pdoc/generators/html/helpers.rb', line 141

def method_synopsis(object)
  result = []
  object.signatures.each do |signature|
    if return_value = signature.return_value
      types = auto_link_types(return_value, :name => :long).join(' | ')
      result << "#{signature.name} &rarr; #{types}"
    else # Constructors
      result << signature.name
    end
  end
  result
end

#methodize_full_name(obj) ⇒ Object



137
138
139
# File 'lib/pdoc/generators/html/helpers.rb', line 137

def methodize_full_name(obj)
  obj.full_name.sub(/\.([^.]+)$/, '#\1')
end

#methodize_signature(sig) ⇒ Object



128
129
130
131
132
133
134
135
# File 'lib/pdoc/generators/html/helpers.rb', line 128

def methodize_signature(sig)
  sig.sub(/\.([\w\d\$]+)\((.*?)(,\s*|\))/) do
    first_arg = $2.to_s.strip
    prefix = first_arg[-1, 1] == '[' ? '([' : '('
    rest = $3 == ')' ? $3 : ''
    "##{$1}#{prefix}#{rest}"
  end
end