aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/markup
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-19 05:08:28 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-19 05:08:28 +0000
commit75ef9e79d6f872d9155cfa69d717b0c693be7fc9 (patch)
tree97fa40e34793b267292d9d769150292a43f3838e /lib/rdoc/markup
parent37e59f5583c781e98f41608251e094377237a133 (diff)
downloadruby-75ef9e79d6f872d9155cfa69d717b0c693be7fc9.tar.gz
Import RDoc 2.5.4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/markup')
-rw-r--r--lib/rdoc/markup/to_html_crossref.rb34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb
index 1f62ee04f9..44e71486fb 100644
--- a/lib/rdoc/markup/to_html_crossref.rb
+++ b/lib/rdoc/markup/to_html_crossref.rb
@@ -21,7 +21,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
#
# See CLASS_REGEXP_STR
- METHOD_REGEXP_STR = '(\w+[!?=]?)(?:\([\w.+*/=<>-]*\))?'
+ METHOD_REGEXP_STR = '([a-z]\w*[!?=]?)(?:\([\w.+*/=<>-]*\))?'
##
# Regular expressions matching text that should potentially have
@@ -32,11 +32,14 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
CROSSREF_REGEXP = /(
# A::B::C.meth
- #{CLASS_REGEXP_STR}[\.\#]#{METHOD_REGEXP_STR}
+ #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
# Stand-alone method (proceeded by a #)
| \\?\##{METHOD_REGEXP_STR}
+ # Stand-alone method (proceeded by ::)
+ | ::#{METHOD_REGEXP_STR}
+
# A::B::C
# The stuff after CLASS_REGEXP_STR is a
# nasty hack. CLASS_REGEXP_STR unfortunately matches
@@ -86,11 +89,11 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
end
##
- # We're invoked when any text matches the CROSSREF pattern (defined in
- # MarkUp). If we find 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 Generator:: prefix, because we look for it in module Generator first.
+ # We're invoked when any text matches the CROSSREF pattern. If we find 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 Generator:: prefix,
+ # because we look for it in module Generator first.
def handle_special_CROSSREF(special)
name = special.text
@@ -102,12 +105,9 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
return @seen[name] if @seen.include? name
- if name[0, 1] == '#' then
- lookup = name[1..-1]
- name = lookup unless @show_hash
- else
- lookup = name
- end
+ lookup = name
+
+ name = name[0, 1] unless @show_hash if name[0, 1] == '#'
# Find class, module, or method in class or module.
#
@@ -119,9 +119,11 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
# (in which case it would match the last pattern, which just checks
# whether the string as a whole is a known symbol).
- if /#{CLASS_REGEXP_STR}[\.\#]#{METHOD_REGEXP_STR}/ =~ lookup then
+ if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/ =~ lookup then
container = $1
- method = $2
+ type = $2
+ type = '#' if type == '.'
+ method = "#{type}#{$3}"
ref = @context.find_symbol container, method
end
@@ -132,7 +134,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
elsif lookup =~ /^\\/ then
$'
elsif ref and ref.document_self then
- "<a href=\"#{ref.as_href(@from_path)}\">#{name}</a>"
+ "<a href=\"#{ref.as_href @from_path}\">#{name}</a>"
else
name
end