lib/rdoc/cross_reference.rb in rdoc-3.12.2 vs lib/rdoc/cross_reference.rb in rdoc-4.0.0.preview2
- old
+ new
@@ -25,73 +25,80 @@
# cross-reference links generated are passed to add_special. 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 = /(
- # A::B::C.meth
- #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
+ CROSSREF_REGEXP = /(?:^|\s)
+ (
+ (?:
+ # A::B::C.meth
+ #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
- # Stand-alone method (preceded by a #)
- | \\?\##{METHOD_REGEXP_STR}
+ # Stand-alone method (preceded by a #)
+ | \\?\##{METHOD_REGEXP_STR}
- # Stand-alone method (preceded by ::)
- | ::#{METHOD_REGEXP_STR}
+ # Stand-alone method (preceded by ::)
+ | ::#{METHOD_REGEXP_STR}
- # A::B::C
- # The stuff after CLASS_REGEXP_STR is a
- # nasty hack. CLASS_REGEXP_STR unfortunately matches
- # words like dog and cat (these are legal "class"
- # names in Fortran 95). When a word is flagged as a
- # potential cross-reference, limitations in the markup
- # engine suppress other processing, such as typesetting.
- # This is particularly noticeable for contractions.
- # In order that words like "can't" not
- # be flagged as potential cross-references, only
- # flag potential class cross-references if the character
- # after the cross-reference is a space, sentence
- # punctuation, tag start character, or attribute
- # marker.
- | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
+ # A::B::C
+ # The stuff after CLASS_REGEXP_STR is a
+ # nasty hack. CLASS_REGEXP_STR unfortunately matches
+ # words like dog and cat (these are legal "class"
+ # names in Fortran 95). When a word is flagged as a
+ # potential cross-reference, limitations in the markup
+ # engine suppress other processing, such as typesetting.
+ # This is particularly noticeable for contractions.
+ # In order that words like "can't" not
+ # be flagged as potential cross-references, only
+ # flag potential class cross-references if the character
+ # after the cross-reference is a space, sentence
+ # punctuation, tag start character, or attribute
+ # marker.
+ | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
- # Things that look like filenames
- # The key thing is that there must be at least
- # one special character (period, slash, or
- # underscore).
- | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
+ # Things that look like filenames
+ # The key thing is that there must be at least
+ # one special character (period, slash, or
+ # underscore).
+ | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
- # Things that have markup suppressed
- # Don't process things like '\<' in \<tt>, though.
- # TODO: including < is a hack, not very satisfying.
- | \\[^\s<]
+ # Things that have markup suppressed
+ # Don't process things like '\<' in \<tt>, though.
+ # TODO: including < is a hack, not very satisfying.
+ | \\[^\s<]
)
# labels for headings
- (?:@[\w+%-]+)?/x
+ (?:@[\w+%-]+(?:\.[\w|%-]+)?)?
+ )/x
##
# Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
- ALL_CROSSREF_REGEXP = /(
- # A::B::C.meth
- #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
+ ALL_CROSSREF_REGEXP = /
+ (?:^|\s)
+ (
+ (?:
+ # A::B::C.meth
+ #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
- # Stand-alone method
- | \\?#{METHOD_REGEXP_STR}
+ # Stand-alone method
+ | \\?#{METHOD_REGEXP_STR}
- # A::B::C
- | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
+ # A::B::C
+ | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
- # Things that look like filenames
- | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
+ # Things that look like filenames
+ | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
- # Things that have markup suppressed
- | \\[^\s<]
+ # Things that have markup suppressed
+ | \\[^\s<]
)
# labels for headings
- (?:@[\w+%-]+)?/x
+ (?:@[\w+%-]+)?
+ )/x
##
# Hash of references that have been looked-up to their replacements
attr_accessor :seen
@@ -100,10 +107,11 @@
# Allows cross-references to be created based on the given +context+
# (RDoc::Context).
def initialize context
@context = context
+ @store = context.store
@seen = {}
end
##
@@ -144,10 +152,10 @@
else
@context.find_symbol name
end unless ref
# Try a page name
- ref = RDoc::TopLevel.page name if not ref and name =~ /^\w+$/
+ ref = @store.page name if not ref and name =~ /^\w+$/
ref = nil if RDoc::Alias === ref # external alias, can't link to it
out = if name == '\\' then
name