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

Update to RDoc 2.5.3

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2010-04-11 01:34:28 +00:00
parent 48a68756f5
commit ff5366a705
5 changed files with 134 additions and 32 deletions

View file

@ -1,3 +1,7 @@
Sun Apr 11 10:33:34 2010 Eric Hodel <drbrain@segment7.net>
* lib/rdoc: Update to RDoc 2.5.3. Includes r27288 and r27290.
Sun Apr 11 09:31:39 2010 Aaron Patterson <aaron@tenderlovemaking.com> Sun Apr 11 09:31:39 2010 Aaron Patterson <aaron@tenderlovemaking.com>
* test/syck/*: Moved test/yaml to test/syck since it's actually * test/syck/*: Moved test/yaml to test/syck since it's actually

2
NEWS
View file

@ -201,7 +201,7 @@ with all sufficient information, see the ChangeLog file.
* RDoc * RDoc
* Updated to RDoc 2.5.2 * Updated to RDoc 2.5.3
* logger * logger

View file

@ -383,7 +383,7 @@ module RDoc
## ##
# RDoc version you are using # RDoc version you are using
VERSION = '2.5.2' VERSION = '2.5.3'
## ##
# Name of the dotfile that contains the description of files to be processed # Name of the dotfile that contains the description of files to be processed

View file

@ -37,6 +37,11 @@ class RDoc::RDoc
attr_accessor :generator attr_accessor :generator
##
# Hash of files and their last modified times.
attr_reader :last_modified
## ##
# RDoc options # RDoc options
@ -75,13 +80,13 @@ class RDoc::RDoc
end end
def initialize def initialize
@current = nil @current = nil
@exclude = nil @exclude = nil
@generator = nil @generator = nil
@last_created = {} @last_modified = {}
@old_siginfo = nil @old_siginfo = nil
@options = nil @options = nil
@stats = nil @stats = nil
end end
## ##
@ -132,35 +137,39 @@ class RDoc::RDoc
# contain the flag file <tt>created.rid</tt> then we refuse to use it, as # contain the flag file <tt>created.rid</tt> then we refuse to use it, as
# we may clobber some manually generated documentation # we may clobber some manually generated documentation
def setup_output_dir(op_dir, force) def setup_output_dir(dir, force)
flag_file = output_flag_file op_dir flag_file = output_flag_file dir
last = {} last = {}
if File.exist? op_dir then if File.exist? dir then
unless File.directory? op_dir then error "#{dir} exists and is not a directory" unless File.directory? dir
error "'#{op_dir}' exists, and is not a directory"
end
begin begin
open flag_file do |io| open flag_file do |io|
unless force unless force then
Time.parse io.gets Time.parse io.gets
io.each do |line| io.each do |line|
file, time = line.split(/\t/, 2) file, time = line.split "\t", 2
time = Time.parse(time) rescue next time = Time.parse(time) rescue next
last[file] = time last[file] = time
end end
end end
end end
rescue rescue SystemCallError, TypeError
error "\nDirectory #{op_dir} already exists, but it looks like it\n" + error <<-ERROR
"isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
"destroying any of your existing files, you'll need to\n" + Directory #{dir} already exists, but it looks like it isn't an RDoc directory.
"specify a different output directory name (using the\n" +
"--op <dir> option).\n\n" Because RDoc doesn't want to risk destroying any of your existing files,
you'll need to specify a different output directory name (using the --op <dir>
option)
ERROR
end end
else else
FileUtils.mkdir_p(op_dir) FileUtils.mkdir_p dir
end end
last last
@ -170,7 +179,7 @@ class RDoc::RDoc
# Update the flag file in an output directory. # Update the flag file in an output directory.
def update_output_dir(op_dir, time, last = {}) def update_output_dir(op_dir, time, last = {})
File.open(output_flag_file(op_dir), "w") do |f| open output_flag_file(op_dir), "w" do |f|
f.puts time.rfc2822 f.puts time.rfc2822
last.each do |n, t| last.each do |n, t|
f.puts "#{n}\t#{t.rfc2822}" f.puts "#{n}\t#{t.rfc2822}"
@ -226,12 +235,12 @@ class RDoc::RDoc
case type = stat.ftype case type = stat.ftype
when "file" then when "file" then
next if last_created = @last_created[rel_file_name] and next if last_modified = @last_modified[rel_file_name] and
stat.mtime.to_i <= last_created.to_i stat.mtime.to_i <= last_modified.to_i
if force_doc or RDoc::Parser.can_parse(rel_file_name) then if force_doc or RDoc::Parser.can_parse(rel_file_name) then
file_list << rel_file_name.sub(/^\.\//, '') file_list << rel_file_name.sub(/^\.\//, '')
@last_created[rel_file_name] = stat.mtime @last_modified[rel_file_name] = stat.mtime
end end
when "directory" then when "directory" then
next if rel_file_name == "CVS" || rel_file_name == ".svn" next if rel_file_name == "CVS" || rel_file_name == ".svn"
@ -356,7 +365,7 @@ The internal error was:
@exclude = @options.exclude @exclude = @options.exclude
@last_created = setup_output_dir @options.op_dir, @options.force_update @last_modified = setup_output_dir @options.op_dir, @options.force_update
start_time = Time.now start_time = Time.now
@ -382,7 +391,7 @@ The internal error was:
self.class.current = self self.class.current = self
@generator.generate file_info @generator.generate file_info
update_output_dir ".", start_time, @last_created update_output_dir ".", start_time, @last_modified
ensure ensure
self.class.current = nil self.class.current = nil
end end
@ -396,7 +405,7 @@ The internal error was:
end end
def read_file_contents(filename) def read_file_contents(filename)
content = File.open(filename, "rb") { |f| f.read } content = open filename, "rb" do |f| f.read end
if defined? Encoding then if defined? Encoding then
if /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.*\n)?.*\n"] if /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.*\n)?.*\n"]

View file

@ -1,4 +1,5 @@
require 'tempfile' require 'tempfile'
require 'tmpdir'
require 'rubygems' require 'rubygems'
require 'minitest/autorun' require 'minitest/autorun'
require 'rdoc/rdoc' require 'rdoc/rdoc'
@ -11,7 +12,7 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
end end
def teardown def teardown
@tempfile.close @tempfile.close rescue nil # HACK for 1.8.6
end end
def test_gather_files def test_gather_files
@ -19,6 +20,24 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
assert_equal [file], @rdoc.gather_files([file, file]) assert_equal [file], @rdoc.gather_files([file, file])
end end
def test_normalized_file_list
files = @rdoc.normalized_file_list [__FILE__]
files = files.map { |file| File.expand_path file }
assert_equal [File.expand_path(__FILE__)], files
end
def test_normalized_file_list_not_modified
files = [__FILE__]
@rdoc.last_modified[__FILE__] = File.stat(__FILE__).mtime
files = @rdoc.normalized_file_list [__FILE__]
assert_empty files
end
def test_read_file_contents def test_read_file_contents
@tempfile.write "hi everybody" @tempfile.write "hi everybody"
@tempfile.flush @tempfile.flush
@ -62,5 +81,75 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
assert_empty @rdoc.remove_unparseable file_list assert_empty @rdoc.remove_unparseable file_list
end end
def test_setup_output_dir
path = @tempfile.path
@tempfile.unlink
last = @rdoc.setup_output_dir path, false
assert_empty last
assert File.directory? path
ensure
FileUtils.rm_f path
end
def test_setup_output_dir_exists
path = @tempfile.path
@tempfile.unlink
FileUtils.mkdir_p path
open @rdoc.output_flag_file(path), 'w' do |io|
io.puts Time.at 0
io.puts "./lib/rdoc.rb\t#{Time.at 86400}"
end
last = @rdoc.setup_output_dir path, false
assert_equal 1, last.size
assert_equal Time.at(86400), last['./lib/rdoc.rb']
ensure
FileUtils.rm_f path
end
def test_setup_output_dir_exists_empty_created_rid
path = @tempfile.path
@tempfile.unlink
FileUtils.mkdir_p path
open @rdoc.output_flag_file(path), 'w' do end
e = assert_raises RDoc::Error do
@rdoc.setup_output_dir path, false
end
assert_match %r%Directory #{Regexp.escape path} already exists%, e.message
ensure
FileUtils.rm_f path
end
def test_setup_output_dir_exists_file
path = @tempfile.path
e = assert_raises RDoc::Error do
@rdoc.setup_output_dir path, false
end
assert_match(%r%#{Regexp.escape path} exists and is not a directory%,
e.message)
end
def test_setup_output_dir_exists_not_rdoc
skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir
Dir.mktmpdir do |dir|
e = assert_raises RDoc::Error do
@rdoc.setup_output_dir dir, false
end
assert_match %r%Directory #{Regexp.escape dir} already exists%, e.message
end
end
end end