SM::ToHtml
Subclass of the SM::ToHtml class that supports looking up words in the AllReferences list. Those that are found (like AllReferences in this comment) will be hyperlinked
Subclass of the SM::ToHtml class that supports looking up words in the AllReferences list. Those that are found (like AllReferences in this comment) will be hyperlinked
We need to record the html path of our caller so we can generate correct relative paths for any hyperlinks that we find
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 88 88: def initialize(from_path, context) 89: super() 90: @from_path = from_path 91: 92: @parent_name = context.parent_name 93: @parent_name += "::" if @parent_name 94: @context = context 95: end
We need to record the html path of our caller so we can generate correct relative paths for any hyperlinks that we find
# File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 88 88: def initialize(from_path, context) 89: super() 90: @from_path = from_path 91: 92: @parent_name = context.parent_name 93: @parent_name += "::" if @parent_name 94: @context = context 95: end
Generate a hyperlink for url, labeled with text. Handle the special cases for img: and link: described under handle_special_HYPEDLINK
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 131 131: def gen_url(url, text) 132: if url =~ /([A-Za-z]+):(.*)/ 133: type = $1 134: path = $2 135: else 136: type = "http" 137: path = url 138: url = "http://#{url}" 139: end 140: 141: if type == "link" 142: url = path 143: end 144: 145: if (type == "http" || type == "link") && url =~ /\.(gif|png|jpg|jpeg|bmp)$/ 146: "<img src=\"#{url}\">" 147: elsif (type == "http" || type == "link") 148: "<a href=\"#{url}\" target=\"_blank\">#{text}</a>" 149: else 150: "<a href=\"#\" onclick=\"jsHref('#{url}');\">#{text.sub(%r{^#{type}:/*}, '')}</a>" 151: 152: end 153: end
Generate a hyperlink for url, labeled with text. Handle the special cases for img: and link: described under handle_special_HYPEDLINK
# File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 131 131: def gen_url(url, text) 132: if url =~ /([A-Za-z]+):(.*)/ 133: type = $1 134: path = $2 135: else 136: type = "http" 137: path = url 138: url = "http://#{url}" 139: end 140: 141: if type == "link" 142: url = path 143: end 144: 145: if (type == "http" || type == "link") && url =~ /\.(gif|png|jpg|jpeg|bmp)$/ 146: "<img src=\"#{url}\">" 147: elsif (type == "http" || type == "link") 148: "<a href=\"#{url}\" target=\"_blank\">#{text}</a>" 149: else 150: "<a href=\"#\" onclick=\"jsHref('#{url}');\">#{text.sub(%r{^#{type}:/*}, '')}</a>" 151: 152: end 153: end
We’re invoked when any text matches the CROSSREF pattern (defined in MarkUp). If we fine the corresponding reference, generate a hyperlink. If the name we’re looking for contains no punctuation, we look for it up the module/class chain. For
example, HyperlinkHtml is found, even without the Generators |
prefix, because we look for it in module Generators first.
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 104 104: def handle_special_CROSSREF(special) 105: name = special.text 106: if name[0,1] == '#' 107: lookup = name[1..1] 108: name = lookup unless Options.instance.show_hash 109: else 110: lookup = name 111: end 112: 113: if /([A-Z].*)[.\#](.*)/ =~ lookup 114: container = $1 115: method = $2 116: ref = @context.find_symbol(container, method) 117: else 118: ref = @context.find_symbol(lookup) 119: end 120: 121: if ref and ref.document_self 122: "<a href=\"index.html?a=#{ref.aref}&name=#{name}\">#{name}</a>" 123: else 124: name #it does not need to be a link 125: end 126: end
We’re invoked when any text matches the CROSSREF pattern (defined in MarkUp). If we fine the corresponding reference, generate a hyperlink. If the name we’re looking for contains no punctuation, we look for it up the module/class chain. For
example, HyperlinkHtml is found, even without the Generators |
prefix, because we look for it in module Generators first.
# File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 104 104: def handle_special_CROSSREF(special) 105: name = special.text 106: if name[0,1] == '#' 107: lookup = name[1..1] 108: name = lookup unless Options.instance.show_hash 109: else 110: lookup = name 111: end 112: 113: if /([A-Z].*)[.\#](.*)/ =~ lookup 114: container = $1 115: method = $2 116: ref = @context.find_symbol(container, method) 117: else 118: ref = @context.find_symbol(lookup) 119: end 120: 121: if ref and ref.document_self 122: "<a href=\"index.html?a=#{ref.aref}&name=#{name}\">#{name}</a>" 123: else 124: name #it does not need to be a link 125: end 126: end
And we’re invoked with a potential external hyperlink mailto: just
gets inserted. http: links are checked to see if they reference an image.
If so, that image gets inserted using an tag. Otherwise a
conventional is used. We also support a special type of
hyperlink, link:, which is a reference to a local file whose path is
relative to the —op directory.
# File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 162 162: def handle_special_HYPERLINK(special) 163: url = special.text 164: gen_url(url, url) 165: end
And we’re invoked with a potential external hyperlink mailto: just
gets inserted. http: links are checked to see if they reference an image.
If so, that image gets inserted using an tag. Otherwise a
conventional is used. We also support a special type of
hyperlink, link:, which is a reference to a local file whose path is
relative to the —op directory.
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 162 162: def handle_special_HYPERLINK(special) 163: url = special.text 164: gen_url(url, url) 165: end
HEre’s a hypedlink where the label is different to the URL
<label>[url]
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 171 171: def handle_special_TIDYLINK(special) 172: text = special.text 173: # unless text =~ /(\S+)\[(.*?)\]/ 174: unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/ 175: return text 176: end 177: label = $1 178: url = $2 179: gen_url(url, label) 180: end
HEre’s a hypedlink where the label is different to the URL
<label>[url]
# File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 171 171: def handle_special_TIDYLINK(special) 172: text = special.text 173: # unless text =~ /(\S+)\[(.*?)\]/ 174: unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/ 175: return text 176: end 177: label = $1 178: url = $2 179: gen_url(url, label) 180: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.