From 41db49c4856d36a13f89ceca6e4cdb744d1de046 Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 4 Aug 2020 15:46:39 +0900 Subject: [PATCH] Support full filename to make a link for a text file --- lib/rdoc/cross_reference.rb | 2 +- lib/rdoc/store.rb | 2 +- test/rdoc/test_rdoc_store.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb index 2785852387..99a64cd99a 100644 --- a/lib/rdoc/cross_reference.rb +++ b/lib/rdoc/cross_reference.rb @@ -173,7 +173,7 @@ def resolve name, text end unless ref # Try a page name - ref = @store.page name if not ref and name =~ /^\w+$/ + ref = @store.page name if not ref and name =~ /^[\w.]+$/ ref = nil if RDoc::Alias === ref # external alias, can't link to it diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb index 05d8383c86..5ba671ca1b 100644 --- a/lib/rdoc/store.rb +++ b/lib/rdoc/store.rb @@ -723,7 +723,7 @@ def modules_hash def page name @text_files_hash.each_value.find do |file| - file.page_name == name + file.page_name == name or file.base_name == name end end diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index 076b8e7d4e..82340e6b7a 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -611,6 +611,14 @@ def test_page assert_equal page, @store.page('PAGE') end + def test_page_with_extension + page = @store.add_file 'PAGE.txt', parser: RDoc::Parser::Simple + + assert_nil @store.page 'no such page' + + assert_equal page, @store.page('PAGE.txt') + end + def test_save FileUtils.mkdir_p @tmpdir