From d5f7af1f9d565b59c710d7a61f629cf90cf28105 Mon Sep 17 00:00:00 2001 From: drbrain Date: Fri, 24 Oct 2008 23:05:28 +0000 Subject: Import RDoc 2.2.2 r192 git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/parser.rb | 14 +++++++++++++- lib/rdoc/parser/c.rb | 1 + lib/rdoc/ri/display.rb | 9 ++++----- lib/rdoc/ri/paths.rb | 6 ++---- 4 files changed, 20 insertions(+), 10 deletions(-) (limited to 'lib/rdoc') diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index 6855cfcfc..c37256dbd 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -68,7 +68,12 @@ class RDoc::Parser def self.binary?(file) s = (File.read(file, File.stat(file).blksize) || "").split(//) - ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30 + + if s.size > 0 then + ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30 + else + false + end end private_class_method :binary? @@ -106,6 +111,13 @@ class RDoc::Parser parser = can_parse file_name + # + # This method must return a parser. + # + if !parser then + parser = RDoc::Parser::Simple + end + parser.new top_level, file_name, body, options, stats end diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb index a5b06c2b0..9061841be 100644 --- a/lib/rdoc/parser/c.rb +++ b/lib/rdoc/parser/c.rb @@ -1,4 +1,5 @@ require 'rdoc/parser' +require 'rdoc/parser/ruby' require 'rdoc/known_classes' ## diff --git a/lib/rdoc/ri/display.rb b/lib/rdoc/ri/display.rb index 05a7cf253..7b0158c18 100644 --- a/lib/rdoc/ri/display.rb +++ b/lib/rdoc/ri/display.rb @@ -5,8 +5,8 @@ require 'rdoc/ri' begin require('readline') require('abbrev') - CAN_USE_READLINE = true -rescue + CAN_USE_READLINE = true # HACK use an RDoc namespace constant +rescue LoadError CAN_USE_READLINE = false end @@ -53,7 +53,7 @@ class RDoc::RI::DefaultDisplay def display_class_info(klass) page do - superclass = klass.superclass_string + superclass = klass.superclass if superclass superclass = " < " + superclass @@ -217,7 +217,7 @@ class RDoc::RI::DefaultDisplay end method_names.sort! - @formatter.wrap method_names.join(',') + @formatter.wrap method_names.join(', ') end end @@ -390,4 +390,3 @@ class RDoc::RI::DefaultDisplay end end - diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb index 037606ec2..2f72b9dfd 100644 --- a/lib/rdoc/ri/paths.rb +++ b/lib/rdoc/ri/paths.rb @@ -28,15 +28,13 @@ module RDoc::RI::Paths VERSION = RbConfig::CONFIG['ruby_version'] - ri = RbConfig::CONFIG['RUBY_INSTALL_NAME'].sub(/ruby/, 'ri') - base = File.join(RbConfig::CONFIG['datadir'], ri, VERSION) + base = File.join(RbConfig::CONFIG['datadir'], "ri", VERSION) SYSDIR = File.join(base, "system") SITEDIR = File.join(base, "site") homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH'] if homedir then - rdoc = RbConfig::CONFIG['RUBY_INSTALL_NAME'].sub(/ruby/, 'rdoc') - HOMEDIR = File.join(homedir, ".#{rdoc}") + HOMEDIR = File.join(homedir, ".rdoc") else HOMEDIR = nil end -- cgit