Skip to content

Commit 8c87409

Browse files
committed
Handle [] and other specials. Issue #41
1 parent 7618fb2 commit 8c87409

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

History.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* Bug fixes
88
* Updating Object in an ri data store with new data now removes methods,
99
includes, constants and aliases.
10+
* `ri []` and other special methods now work properly. Issue #52 by
11+
ddebernardy.
1012

1113
=== 3.7 / 2011-06-27
1214

lib/rdoc/ri/driver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,11 +1090,11 @@ def paging?
10901090
# NOTE: Given Foo::Bar, Bar is considered a class even though it may be a
10911091
# method
10921092

1093-
def parse_name(name)
1093+
def parse_name name
10941094
parts = name.split(/(::|#|\.)/)
10951095

10961096
if parts.length == 1 then
1097-
if parts.first =~ /^[a-z]/ then
1097+
if parts.first =~ /^[a-z]|^([%&*+\/<>^`|~-]|\+@|-@|<<|<=>?|===?|=>|=~|>>|\[\]=?|~@)$/ then
10981098
type = '.'
10991099
meth = parts.pop
11001100
else

test/test_rdoc_ri_driver.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,42 @@ def test_parse_name_namespace
805805
assert_equal 'baz', meth, 'Foo::Bar#baz method'
806806
end
807807

808+
def test_parse_name_special
809+
specials = %w[
810+
%
811+
&
812+
*
813+
+
814+
+@
815+
-
816+
-@
817+
/
818+
<
819+
<<
820+
<=
821+
<=>
822+
==
823+
===
824+
=>
825+
=~
826+
>
827+
>>
828+
[]
829+
[]=
830+
^
831+
`
832+
|
833+
~
834+
~@
835+
]
836+
837+
specials.each do |special|
838+
parsed = @driver.parse_name special
839+
840+
assert_equal ['', '.', special], parsed
841+
end
842+
end
843+
808844
def _test_setup_pager # this test doesn't do anything anymore :(
809845
@driver.use_stdout = false
810846

0 commit comments

Comments
 (0)