diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index 3bb6f5d1f2..425105effa 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -125,9 +125,11 @@ def self.can_parse_by_name file_name return parser if ext_name.empty? if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/ then - case check_modeline file_name + case mode = check_modeline(file_name) when nil, 'rdoc' then # continue - else return nil + else + RDoc::Parser.parsers.find { |_, p| return p if mode.casecmp?(p.name[/\w+\z/]) } + return nil end end diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb index 7cc3c2d926..a19986bd26 100644 --- a/test/rdoc/test_rdoc_parser.rb +++ b/test/rdoc/test_rdoc_parser.rb @@ -147,10 +147,23 @@ def test_can_parse_modeline end assert_equal RDoc::Parser::Simple, @RP.can_parse(readme_ext) + end + + def test_can_parse_modeline_c + readme_inc = File.join Dir.tmpdir, "README.inc.#{$$}" + + File.open readme_inc, 'w' do |io| + io.puts "/* README.inc - -*- c -*- created at: Mon Aug 7 16:45:54 JST 1995 */" + io.puts + io.puts "/* This document explains how to make extension libraries for Ruby. */" + end + + assert_equal RDoc::Parser::C, @RP.can_parse(readme_inc) ensure - File.unlink readme_ext + File.unlink readme_inc end + ## # Selenium hides a .jar file using a .txt extension.