mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rdoc: --extension option fix
* lib/rdoc/parser.rb (RDoc.alias_extension): a real file is irrelevant to aliasing. [ruby-core:44796][Bug #6392] * lib/rdoc/parser.rb (RDoc.zip?): non-existent file will not be a zip file. * lib/rdoc/parser.rb (RDoc.can_parse_by_name): accept aliased extension file names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1348e3b9ac
commit
9bee6cf51f
4 changed files with 37 additions and 4 deletions
|
@ -61,7 +61,7 @@ class RDoc::Parser
|
|||
old_ext = old_ext.sub(/^\.(.*)/, '\1')
|
||||
new_ext = new_ext.sub(/^\.(.*)/, '\1')
|
||||
|
||||
parser = can_parse "xxx.#{old_ext}"
|
||||
parser = can_parse_by_name "xxx.#{old_ext}"
|
||||
return false unless parser
|
||||
|
||||
RDoc::Parser.parsers.unshift [/\.#{new_ext}$/, parser]
|
||||
|
@ -134,21 +134,29 @@ class RDoc::Parser
|
|||
zip_signature == "PK\x03\x04" or
|
||||
zip_signature == "PK\x05\x06" or
|
||||
zip_signature == "PK\x07\x08"
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
##
|
||||
# Return a parser that can handle a particular extension
|
||||
|
||||
def self.can_parse(file_name)
|
||||
parser = RDoc::Parser.parsers.find { |regexp,| regexp =~ file_name }.last
|
||||
parser = can_parse_by_name(file_name)
|
||||
|
||||
# HACK Selenium hides a jar file using a .txt extension
|
||||
return if parser == RDoc::Parser::Simple and zip? file_name
|
||||
|
||||
parser
|
||||
end
|
||||
|
||||
def self.can_parse_by_name(file_name)
|
||||
pattern, parser = RDoc::Parser.parsers.find { |regexp,| regexp =~ file_name }
|
||||
|
||||
# The default parser must not parse binary files
|
||||
ext_name = File.extname file_name
|
||||
return parser if ext_name.empty?
|
||||
return if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/
|
||||
return if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/ and file_name[pattern].empty?
|
||||
|
||||
parser
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue