1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rdoc/usage.rb: improper exceptions. [ruby-dev:26870]

* lib/rdoc/usage.rb: support the case when non-ruby code exists before
  shebang. (this is needed when ri.bat is executed on windows)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ocean 2005-08-29 10:56:05 +00:00
parent 6f23ba054a
commit 7c755d4174
2 changed files with 31 additions and 17 deletions

View file

@ -1,3 +1,10 @@
Mon Aug 29 19:47:18 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/rdoc/usage.rb: improper exceptions. [ruby-dev:26870]
* lib/rdoc/usage.rb: support the case when non-ruby code exists before
shebang. (this is needed when ri.bat is executed on windows)
Mon Aug 29 18:58:05 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
* lib/irb/init.rb: make IRB -I option that is same befavior for ruby.
[ruby-dev:26872]

View file

@ -128,24 +128,31 @@ module RDoc
# Find the first comment in the file (that isn't a shebang line)
# If the file doesn't start with a comment, report the fact
# and return nil
# and return empty string
def RDoc.gets(file)
if (line = file.gets) && (line =~ /^#!/) # shebang
throw :exit, find_comment(file)
else
line
end
end
def RDoc.find_comment(file)
# skip leading blank lines and shebangs
while line = file.gets
break unless line =~ /^(#!|\s*$)/
catch (:exit) do
# skip leading blank lines
0 while (line = gets(file)) && (line =~ /^\s*$/)
comment = []
while line && line =~ /^\s*#/
comment << line
line = gets(file)
end
0 while line && (line = gets(file))
return no_comment if comment.empty?
return comment.join
end
comment = []
while line && line =~ /^\s*#/
comment << line
line = file.gets
end
return no_comment if comment.empty?
comment.join
end
@ -167,7 +174,7 @@ module RDoc
if copy_upto_level && item.level >= copy_upto_level
copy_upto_level = nil
else
if item.text[0].downcase == name
if item.text.downcase == name
result << item
copy_upto_level = item.level
end
@ -191,7 +198,7 @@ module RDoc
# Report the fact that no doc comment count be found
def RDoc.no_comment
$stderr.puts "No usage information available for this program"
nil
""
end
end