Skip to content

Commit

Permalink
Merge pull request #632 from TheSmartnik/improve_cross_reference_regex
Browse files Browse the repository at this point in the history
Allow `#+`, `#-`, `#`' to be cross referenced
  • Loading branch information
aycabta authored Jun 23, 2018
2 parents 9c93b31 + 0e65554 commit c642102
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
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

0 comments on commit c642102

Please sign in to comment.