mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rdoc/encoding.rb: Do not remove #! line from document when
setting encoding. This allows ruby executables to be parsed as ruby files. * test/rdoc/test_rdoc_encoding.rb: Test for above. * lib/rdoc/parser.rb: Set the parser file name of ruby executables correctly. * test/rdoc/test_rdoc_parser.rb: Test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aa233d3f33
commit
dff59f6c5d
5 changed files with 37 additions and 4 deletions
|
@ -45,6 +45,11 @@ class RDoc::Parser
|
|||
|
||||
end
|
||||
|
||||
##
|
||||
# The name of the file being parsed
|
||||
|
||||
attr_reader :file_name
|
||||
|
||||
##
|
||||
# Alias an extension to another extension. After this call, files ending
|
||||
# "new_ext" will be parsed using the same parser as "old_ext"
|
||||
|
@ -182,16 +187,18 @@ class RDoc::Parser
|
|||
parser = use_markup content
|
||||
|
||||
unless parser then
|
||||
parse_name = file_name
|
||||
|
||||
# If no extension, look for shebang
|
||||
if file_name !~ /\.\w+$/ && content =~ %r{\A#!(.+)} then
|
||||
shebang = $1
|
||||
case shebang
|
||||
when %r{env\s+ruby}, %r{/ruby}
|
||||
file_name = "dummy.rb"
|
||||
parse_name = 'dummy.rb'
|
||||
end
|
||||
end
|
||||
|
||||
parser = can_parse file_name
|
||||
parser = can_parse parse_name
|
||||
end
|
||||
|
||||
return unless parser
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue