From ebc66662d1f98eecc694c1fd39ac5446198bff34 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Thu, 3 Jan 2013 17:54:30 -0800 Subject: [PATCH] RDoc can now link #=== methods The METHOD_REGEXP_STR was missing === so it could not be linked. Fixes #164 --- History.rdoc | 1 + lib/rdoc/cross_reference.rb | 2 +- test/test_rdoc_cross_reference.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/History.rdoc b/History.rdoc index e335f1f931..107eed493b 100644 --- a/History.rdoc +++ b/History.rdoc @@ -26,6 +26,7 @@ to build HTML documentation when installing gems.) * RDoc now ignores methods defined on constants instead of creating a fake module. Bug #163 by Zachary Scott. * Fixed ChangeLog parsing for FFI gem. Bug #165 by Zachary Scott. + * RDoc now links \#=== methods. Bug #164 by Zachary Scott. === 4.0.0.preview2.1 / 2012-12-14 diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb index c6f127387c..2cb0571732 100644 --- a/lib/rdoc/cross_reference.rb +++ b/lib/rdoc/cross_reference.rb @@ -18,7 +18,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 diff --git a/test/test_rdoc_cross_reference.rb b/test/test_rdoc_cross_reference.rb index 45afd80d31..ecb5f9aa41 100644 --- a/test/test_rdoc_cross_reference.rb +++ b/test/test_rdoc_cross_reference.rb @@ -16,6 +16,14 @@ def refute_ref name assert_equal name, @xref.resolve(name, name) end + def test_METHOD_REGEXP_STR + re = /#{RDoc::CrossReference::METHOD_REGEXP_STR}/ + + re =~ '===' + + assert_equal '===', $& + end + def test_resolve_C2 @xref = RDoc::CrossReference.new @c2 @@ -129,6 +137,13 @@ def test_resolve_method assert_ref @c2_c3_m, '::C2::C3#m(*)' end + def test_resolve_method_equals3 + m = RDoc::AnyMethod.new '', '===' + @c1.add_method m + + assert_ref m, '===' + end + def test_resolve_page page = @store.add_file 'README.txt' page.parser = RDoc::Parser::Simple