Feature #3023 ยป rdoc_url.patch
lib/rdoc/any_method.rb | ||
---|---|---|
require 'rdoc/code_object'
|
||
require 'rdoc/tokenstream'
|
||
require 'cgi'
|
||
##
|
||
# AnyMethod is the base class for objects representing methods
|
||
... | ... | |
##
|
||
# Fragment reference for this method
|
||
attr_reader :aref
|
||
def aref
|
||
"#{CGI::escape(name)}-#{singleton ? 'class_method' : 'instance_method'}"
|
||
end
|
||
##
|
||
# The method we're aliasing
|
||
... | ... | |
##
|
||
# Resets method fragment reference counter
|
||
# (obsolete)
|
||
def self.reset
|
||
@@aref = 'M000000'
|
||
end
|
||
reset
|
||
... | ... | |
@singleton = nil
|
||
@token_stream = nil
|
||
@visibility = :public
|
||
@aref = @@aref
|
||
@@aref = @@aref.succ
|
||
end
|
||
##
|
||
... | ... | |
# Path to this method
|
||
def path
|
||
"#{@parent.path}##{@aref}"
|
||
"#{@parent.path}##{aref}"
|
||
end
|
||
##
|
lib/rdoc/rdoc.rb | ||
---|---|---|
def document(argv)
|
||
RDoc::TopLevel.reset
|
||
RDoc::Parser::C.reset
|
||
RDoc::AnyMethod.reset
|
||
@options = RDoc::Options.new
|
||
@options.parse argv
|
test/rdoc/test_rdoc_markup_to_html_crossref.rb | ||
---|---|---|
refute_ref '#m', '#m'
|
||
assert_ref '../C2/C3.html', 'C2::C3'
|
||
assert_ref '../C2/C3.html#M000002', 'C2::C3#m'
|
||
assert_ref '../C2/C3.html#m-instance_method', 'C2::C3#m'
|
||
assert_ref '../C2/C3/H1.html', 'C3::H1'
|
||
assert_ref '../C4.html', 'C4'
|
||
... | ... | |
def test_handle_special_CROSSREF_C2_C3
|
||
@xref = RDoc::Markup::ToHtmlCrossref.new 'classes/C2/C3.html', @c2_c3, true
|
||
assert_ref '../../C2/C3.html#M000002', '#m'
|
||
assert_ref '../../C2/C3.html#m-instance_method', '#m'
|
||
assert_ref '../../C2/C3.html', 'C3'
|
||
assert_ref '../../C2/C3.html#M000002', 'C3#m'
|
||
assert_ref '../../C2/C3.html#m-instance_method', 'C3#m'
|
||
assert_ref '../../C2/C3/H1.html', 'H1'
|
||
assert_ref '../../C2/C3/H1.html', 'C3::H1'
|
||
... | ... | |
def test_handle_special_CROSSREF_method
|
||
refute_ref 'm', 'm'
|
||
assert_ref 'C1.html#M000000', '#m'
|
||
# Bug: cross ref doesn't distinguish instance methods from class methods currently.
|
||
# Ideally, the lines marked with "BUG" below should be modified whenever this is fixed
|
||
assert_ref 'C1.html#m-class_method', '#m' # BUG
|
||
assert_ref 'C1.html#M000000', 'C1#m'
|
||
assert_ref 'C1.html#M000000', 'C1#m()'
|
||
assert_ref 'C1.html#M000000', 'C1#m(*)'
|
||
assert_ref 'C1.html#m-class_method', 'C1#m' # BUG
|
||
assert_ref 'C1.html#m-class_method', 'C1#m()' # BUG
|
||
assert_ref 'C1.html#m-class_method', 'C1#m(*)' # BUG
|
||
assert_ref 'C1.html#M000000', 'C1.m'
|
||
assert_ref 'C1.html#M000000', 'C1.m()'
|
||
assert_ref 'C1.html#M000000', 'C1.m(*)'
|
||
assert_ref 'C1.html#m-class_method', 'C1.m'
|
||
assert_ref 'C1.html#m-class_method', 'C1.m()'
|
||
assert_ref 'C1.html#m-class_method', 'C1.m(*)'
|
||
# HACK should this work
|
||
#assert_ref 'classes/C1.html#M000001', 'C1::m'
|
||
#assert_ref 'classes/C1.html#M000001', 'C1::m()'
|
||
#assert_ref 'classes/C1.html#M000001', 'C1::m(*)'
|
||
assert_ref 'C2/C3.html#M000002', 'C2::C3#m'
|
||
assert_ref 'C2/C3.html#m-instance_method', 'C2::C3#m'
|
||
assert_ref 'C2/C3.html#M000002', 'C2::C3.m'
|
||
assert_ref 'C2/C3.html#m-instance_method', 'C2::C3.m' # BUG
|
||
assert_ref 'C2/C3/H1.html#M000003', 'C2::C3::H1#m?'
|
||
assert_ref 'C2/C3/H1.html#m%3F-instance_method', 'C2::C3::H1#m?'
|
||
assert_ref 'C2/C3.html#M000002', '::C2::C3#m'
|
||
assert_ref 'C2/C3.html#M000002', '::C2::C3#m()'
|
||
assert_ref 'C2/C3.html#M000002', '::C2::C3#m(*)'
|
||
assert_ref 'C2/C3.html#m-instance_method', '::C2::C3#m'
|
||
assert_ref 'C2/C3.html#m-instance_method', '::C2::C3#m()'
|
||
assert_ref 'C2/C3.html#m-instance_method', '::C2::C3#m(*)'
|
||
end
|
||
def test_handle_special_CROSSREF_no_ref
|