module YARD::LinkStdlib::HtmlHelper
A helper module to add to {YARD::Templates::Template.extra_includes} to handle linking stdlib references.
@see www.rubydoc.info/gems/yard/YARD%2FTemplates%2FTemplate.extra_includes
Constants
- INCLUDE_FILTER
The {Proc} we pass to
@return [Proc]
Public Instance Methods
link_object(obj, title = nil, anchor = nil, relative = true)
click to toggle source
The only real meat of this whole gem - hook into object linking.
We link to the stdlib if:
-
We didn't link to anything else (local stuff take precedence).
-
We can find a match for the reference.
@see www.rubydoc.info/gems/yard/YARD/Templates/Helpers/HtmlHelper#link_object-instance_method
@param [YARD::CodeObjects::Base] obj
The object to link to.
@param [String?] title
Optional title to display the link as.
@param [nil | ?] anchor
Not sure... not doc'd in YARD.
@param [Boolean] relative
Again, not sure... not doc'd in YARD, but seems like a boolean.
@return [String]
The HTML source for the link.
Calls superclass method
# File lib/yard/link_stdlib/html_helper.rb, line 74 def link_object obj, title = nil, anchor = nil, relative = true # See what the super method can do... super_link = super # Bail out unless `super` returned a {String}, which I'm guessing would be # `nil`, but not sure. unless super_link.is_a?( String ) LinkStdlib.dump "Object not linkable", obj: obj, super_link: super_link return super_link end LinkStdlib.dump "Object *may* be linkable!", obj: obj, super_link: super_link # if ( path = ObjectMap.current.data[ stdlib_key ] ) if (url = ObjectMap.current.url_for super_link) LinkStdlib.dump "Matched stdlib link!", name: super_link, url: url # NOTE `url` is **not** escaped because it may contains '#' followed # by a fragment, and that needs to be preserved. At this point, # I'm just assuming it's ready for use as-is. %(<a href="#{ url }">#{ CGI.escapeHTML super_link }</a>) else LinkStdlib.dump "Got nada.", super_link: super_link super_link end end