lib/yard/templates/helpers/html_helper.rb in yard-0.8.3 vs lib/yard/templates/helpers/html_helper.rb in yard-0.8.4
- old
+ new
@@ -254,21 +254,23 @@
# Check if we're linking to a class method in the current
# object. If we are, create a title in the format of
# "CurrentClass.method_name"
if obj.is_a?(CodeObjects::MethodObject) && obj.scope == :class && obj.parent == object
title = h([object.name, obj.sep, obj.name].join)
+ elsif obj.title != obj.path
+ title = h(obj.title)
else
title = h(object.relative_path(obj))
end
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
+ link = link ? link_url(link, title, :title => h("#{obj.title} (#{obj.type})")) : title
"<span class='object_link'>" + link + "</span>"
end
# (see BaseHelper#link_url)
def link_url(url, title = nil, params = {})
@@ -308,10 +310,11 @@
# @param [Boolean] relative use a relative or absolute link
# @return [String] the URL location of the object
def url_for(obj, anchor = nil, relative = true)
link = nil
return link unless serializer
+ return link if obj.is_a?(CodeObjects::Base) && run_verifier([obj]).empty?
if obj.is_a?(CodeObjects::Base) && !obj.is_a?(CodeObjects::NamespaceObject)
# If the obj is not a namespace obj make it the anchor.
anchor, obj = obj, obj.namespace
end
@@ -580,10 +583,10 @@
if options.highlight
string = html_syntax_highlight(CGI.unescapeHTML(string), language)
end
classes = ['code', language].compact.join(' ')
- %Q{<pre class="#{classes}"><code>#{string}</code></pre>}
+ %Q{<pre class="#{classes}"><code class="#{language}">#{string}</code></pre>}
end
end
end
end
end