Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
run: bundle exec rake
env:
RUBYOPT: --enable-frozen_string_literal
continue-on-error: ${{ startsWith(matrix.ruby, 'truffle') }}
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}
run: bundle exec rake rdoc
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}
Expand Down
6 changes: 4 additions & 2 deletions lib/rdoc/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 14 additions & 1 deletion test/rdoc/test_rdoc_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down