Method: YARD::Templates::Helpers::HtmlHelper#link_object

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

Links to an object with an optional title

Parameters:

Returns:

  • (String)

    the linked object

[View source]

243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/yard/templates/helpers/html_helper.rb', line 243

def link_object(obj, otitle = nil, anchor = nil, relative = true)
  return otitle if obj.nil?
  obj = Registry.resolve(object, obj, true, true) if obj.is_a?(String)
  if !otitle && obj.root?
    title = "Top Level Namespace"
  elsif otitle
    title = otitle.to_s
  elsif object.is_a?(CodeObjects::Base)
    title = h(object.relative_path(obj))
  else
    title = h(obj.to_s)
  end
  return title unless serializer
  return title if obj.is_a?(CodeObjects::Proxy)

  link = url_for(obj, anchor, relative)
  link = link ? link_url(link, title, :title => h("#{obj.path} (#{obj.type})")) : title
  "<span class='object_link'>" + link + "</span>"
end