Skip to content

Allow #+, #-, #' to be cross referenced #632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/cross_reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RDoc::CrossReference
#
# 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
Expand Down
4 changes: 2 additions & 2 deletions test/test_rdoc_any_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_marshal_load_aliased_method_with_nil_singleton
end

def test_marshal_load_class_method
class_method = Marshal.load Marshal.dump(@c1.method_list.first)
class_method = Marshal.load Marshal.dump(@c1.find_class_method_named 'm')

assert_equal 'C1::m', class_method.full_name
assert_equal 'C1', class_method.parent_name
Expand All @@ -174,7 +174,7 @@ def test_marshal_load_class_method
end

def test_marshal_load_instance_method
instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
instance_method = Marshal.load Marshal.dump(@c1.find_instance_method_named 'm')

assert_equal 'C1#m', instance_method.full_name
assert_equal 'C1', instance_method.parent_name
Expand Down
1 change: 1 addition & 0 deletions test/test_rdoc_class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_docuent_self_or_methods

assert @c1.document_self_or_methods

@c1_plus.document_self = false
@c1_m.document_self = false

assert @c1.document_self_or_methods
Expand Down
2 changes: 1 addition & 1 deletion test/test_rdoc_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def test_methods_by_type
'instance' => {
:private => [],
:protected => [],
:public => [@c1_m],
:public => [@c1_plus, @c1_m],
},
'class' => {
:private => [],
Expand Down
20 changes: 13 additions & 7 deletions test/test_rdoc_cross_reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,24 @@ def test_resolve_file
end

def test_resolve_method
assert_ref @c1__m, 'm'
assert_ref @c1_m, '#m'
assert_ref @c1__m, '::m'

assert_ref @c1_m, 'C1#m'
assert_ref @c1__m, 'C1.m'
assert_ref @c1__m, 'C1::m'
assert_ref @c1__m, 'm'
assert_ref @c1__m, '::m'
assert_ref @c1_m, '#m'
assert_ref @c1_plus, '#+'

assert_ref @c1_m, 'C1#m'
assert_ref @c1_plus, 'C1#+'
assert_ref @c1__m, 'C1.m'
assert_ref @c1__m, 'C1::m'

assert_ref @c1_m, 'C1#m'
assert_ref @c1_m, 'C1#m()'
assert_ref @c1_m, 'C1#m(*)'

assert_ref @c1_plus, 'C1#+'
assert_ref @c1_plus, 'C1#+()'
assert_ref @c1_plus, 'C1#+(*)'

assert_ref @c1__m, 'C1.m'
assert_ref @c1__m, 'C1.m()'
assert_ref @c1__m, 'C1.m(*)'
Expand Down
2 changes: 2 additions & 0 deletions test/xref_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def self.m
def m foo
end

def +
end
end

class C2
Expand Down
7 changes: 4 additions & 3 deletions test/xref_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ def generator.file_dir() nil end
@rdoc.options = @options
@rdoc.generator = generator

@c1 = @xref_data.find_module_named 'C1'
@c1_m = @c1.method_list.last # C1#m
@c1__m = @c1.method_list.first # C1::m
@c1 = @xref_data.find_module_named 'C1'
@c1__m = @c1.find_class_method_named 'm' # C1::m
@c1_m = @c1.find_instance_method_named 'm' # C1#m
@c1_plus = @c1.find_instance_method_named '+'

@c2 = @xref_data.find_module_named 'C2'
@c2_a = @c2.method_list.last
Expand Down