Method: Helper::Linker#link_to
- Defined in:
- lib/helper/linker.rb
#link_to(target, text = nil, args = {}) ⇒ Object
Note:
link_to - first argument can be “file:some/path/to_a.file” “Code.object.path” “.relative.code_object.path” “external.address.com” instance_of_code_object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/helper/linker.rb', line 20 def link_to(target, text = nil, args = {}) Logger.debug "Trying to link #{target}" link = if target.is_a? Document::Document text = target.name if text.nil? to_relative path_to target elsif target.is_a? CodeObject::Base if text.nil? and target.parent == context and context != Dom.root text = ".#{target.name}" text += "()" if target.is_a? CodeObject::Function elsif text.nil? text = target.qualified_name end to_relative path_to target elsif target.match EXTERNAL or target.match MAIL or target.match HASH target elsif target.match FILE to_relative target.match(FILE).captures.first elsif target.match DOCUMENTATION Logger.debug target + " matched DOCUMENTATION" doc_name, hash = target.match(DOCUMENTATION).captures obj = Dom.docs.find doc_name text ||= obj.name # find relative path to our object and reattach hash to path to_relative(path_to obj) + (hash || "") unless obj.nil? else # use context dependent resolving functionality as specified in {Tasks::RenderTask} obj = resolve target to_relative path_to obj unless obj.nil? end text ||= target if link.nil? Logger.warn "Could not resolve link to '#{target}'" return text end tag :a, text, :href => link end |