lib/rdoc/cross_reference.rb in rdoc-6.0.4 vs lib/rdoc/cross_reference.rb in rdoc-6.1.0.beta1
- old
+ new
@@ -17,16 +17,16 @@
##
# Regular expression to match method references.
#
# See CLASS_REGEXP_STR
- METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>)(?:\([\w.+*/=<>-]*\))?'
+ METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
##
# Regular expressions matching text that should potentially have
- # cross-reference links generated are passed to add_special. Note that
- # these expressions are meant to pick up text for which cross-references
+ # cross-reference links generated are passed to add_regexp_handling. Note
+ # that these expressions are meant to pick up text for which cross-references
# have been suppressed, since the suppression characters are removed by the
# code that is triggered.
CROSSREF_REGEXP = /(?:^|\s)
(
@@ -125,26 +125,44 @@
def resolve name, text
return @seen[name] if @seen.include? name
if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
type = $2
- type = '' if type == '.' # will find either #method or ::method
- method = "#{type}#{$3}"
+ if '.' == type # will find either #method or ::method
+ method = $3
+ else
+ method = "#{type}#{$3}"
+ end
container = @context.find_symbol_module($1)
elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
type = $1
- type = '' if type == '.'
- method = "#{type}#{$2}"
+ if '.' == type
+ method = $2
+ else
+ method = "#{type}#{$2}"
+ end
container = @context
else
+ type = nil
container = nil
end
if container then
- ref = container.find_local_symbol method
-
- unless ref || RDoc::TopLevel === container then
- ref = container.find_ancestor_local_symbol method
+ unless RDoc::TopLevel === container then
+ if '.' == type then
+ if 'new' == method then # AnyClassName.new will be class method
+ ref = container.find_local_symbol method
+ ref = container.find_ancestor_local_symbol method unless ref
+ else
+ ref = container.find_local_symbol "::#{method}"
+ ref = container.find_ancestor_local_symbol "::#{method}" unless ref
+ ref = container.find_local_symbol "##{method}" unless ref
+ ref = container.find_ancestor_local_symbol "##{method}" unless ref
+ end
+ else
+ ref = container.find_local_symbol method
+ ref = container.find_ancestor_local_symbol method unless ref
+ end
end
end
ref = case name
when /^\\(#{CLASS_REGEXP_STR})$/o then