Permalink
Browse files

Only trim known extensions from page name

Previously any extension on the file was trimmed, but this could give
confusing results.  Now RDoc only trims rb, rdoc, txt and md extensions.

Fixes ruby bug #7673
  • Loading branch information...
1 parent bd48d81 commit 082937c4e7f4d2b1739a6ecfb5d7c39cd95c5e5f @drbrain drbrain committed Jan 14, 2013
Showing with 16 additions and 2 deletions.
  1. +1 −1 lib/rdoc/top_level.rb
  2. +15 −1 test/test_rdoc_top_level.rb
View
@@ -226,7 +226,7 @@ def object_class
def page_name
basename = File.basename @relative_name
- basename =~ /\.[^.]*$/
+ basename =~ /\.(rb|rdoc|txt|md)$/i
$` || basename
end
@@ -214,7 +214,7 @@ def test_name
def test_page_name
assert_equal 'top_level', @top_level.page_name
- tl = @store.add_file 'README.ja.rdoc'
+ tl = @store.add_file 'README.ja'
assert_equal 'README.ja', tl.page_name
@@ -223,6 +223,20 @@ def test_page_name
assert_equal 'Rakefile', tl.page_name
end
+ def test_page_name_trim_extension
+ tl = @store.add_file 'README.ja.rdoc'
+
+ assert_equal 'README.ja', tl.page_name
+
+ tl = @store.add_file 'README.ja.md'
+
+ assert_equal 'README.ja', tl.page_name
+
+ tl = @store.add_file 'README.txt'
+
+ assert_equal 'README', tl.page_name
+ end
+
def test_search_record
assert_nil @xref_data.search_record
end

0 comments on commit 082937c

Please sign in to comment.