@@ -21,7 +21,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
2121 #
2222 # See CLASS_REGEXP_STR
2323
24- METHOD_REGEXP_STR = '(\w+ [!?=]?)(?:\([\w.+*/=<>-]*\))?'
24+ METHOD_REGEXP_STR = '([a-z]\w* [!?=]?)(?:\([\w.+*/=<>-]*\))?'
2525
2626 ##
2727 # Regular expressions matching text that should potentially have
@@ -32,11 +32,14 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
3232
3333 CROSSREF_REGEXP = /(
3434 # A::B::C.meth
35- #{ CLASS_REGEXP_STR } [ \. \# ] #{ METHOD_REGEXP_STR }
35+ #{ CLASS_REGEXP_STR } (?:[.#]|::) #{ METHOD_REGEXP_STR }
3636
3737 # Stand-alone method (proceeded by a #)
3838 | \\ ?\# #{ METHOD_REGEXP_STR }
3939
40+ # Stand-alone method (proceeded by ::)
41+ | ::#{ METHOD_REGEXP_STR }
42+
4043 # A::B::C
4144 # The stuff after CLASS_REGEXP_STR is a
4245 # nasty hack. CLASS_REGEXP_STR unfortunately matches
@@ -86,11 +89,11 @@ def initialize(from_path, context, show_hash)
8689 end
8790
8891 ##
89- # We're invoked when any text matches the CROSSREF pattern (defined in
90- # MarkUp). If we find the corresponding reference, generate a hyperlink.
91- # If the name we're looking for contains no punctuation, we look for it up
92- # the module/class chain. For example, HyperlinkHtml is found, even without
93- # the Generator:: prefix, because we look for it in module Generator first.
92+ # We're invoked when any text matches the CROSSREF pattern. If we find the
93+ # corresponding reference, generate a hyperlink. If the name we're looking
94+ # for contains no punctuation, we look for it up the module/class chain.
95+ # For example, HyperlinkHtml is found, even without the Generator:: prefix,
96+ # because we look for it in module Generator first.
9497
9598 def handle_special_CROSSREF ( special )
9699 name = special . text
@@ -102,12 +105,9 @@ def handle_special_CROSSREF(special)
102105
103106 return @seen [ name ] if @seen . include? name
104107
105- if name [ 0 , 1 ] == '#' then
106- lookup = name [ 1 ..-1 ]
107- name = lookup unless @show_hash
108- else
109- lookup = name
110- end
108+ lookup = name
109+
110+ name = name [ 0 , 1 ] unless @show_hash if name [ 0 , 1 ] == '#'
111111
112112 # Find class, module, or method in class or module.
113113 #
@@ -119,9 +119,11 @@ def handle_special_CROSSREF(special)
119119 # (in which case it would match the last pattern, which just checks
120120 # whether the string as a whole is a known symbol).
121121
122- if /#{ CLASS_REGEXP_STR } [ \. \# ] #{ METHOD_REGEXP_STR } / =~ lookup then
122+ if /#{ CLASS_REGEXP_STR } ([.#]|::) #{ METHOD_REGEXP_STR } / =~ lookup then
123123 container = $1
124- method = $2
124+ type = $2
125+ type = '#' if type == '.'
126+ method = "#{ type } #{ $3} "
125127 ref = @context . find_symbol container , method
126128 end
127129
@@ -132,7 +134,7 @@ def handle_special_CROSSREF(special)
132134 elsif lookup =~ /^\\ / then
133135 $'
134136 elsif ref and ref . document_self then
135- "<a href=\" #{ ref . as_href ( @from_path ) } \" >#{ name } </a>"
137+ "<a href=\" #{ ref . as_href @from_path } \" >#{ name } </a>"
136138 else
137139 name
138140 end
0 commit comments