зеркало из https://github.com/github/ruby.git
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:
Родитель
48a68756f5
Коммит
ff5366a705
|
@ -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>
|
||||
|
||||
* test/syck/*: Moved test/yaml to test/syck since it's actually
|
||||
|
|
2
NEWS
2
NEWS
|
@ -201,7 +201,7 @@ with all sufficient information, see the ChangeLog file.
|
|||
|
||||
* RDoc
|
||||
|
||||
* Updated to RDoc 2.5.2
|
||||
* Updated to RDoc 2.5.3
|
||||
|
||||
* logger
|
||||
|
||||
|
|
|
@ -383,7 +383,7 @@ module RDoc
|
|||
##
|
||||
# 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
|
||||
|
|
|
@ -37,6 +37,11 @@ class RDoc::RDoc
|
|||
|
||||
attr_accessor :generator
|
||||
|
||||
##
|
||||
# Hash of files and their last modified times.
|
||||
|
||||
attr_reader :last_modified
|
||||
|
||||
##
|
||||
# RDoc options
|
||||
|
||||
|
@ -75,13 +80,13 @@ class RDoc::RDoc
|
|||
end
|
||||
|
||||
def initialize
|
||||
@current = nil
|
||||
@exclude = nil
|
||||
@generator = nil
|
||||
@last_created = {}
|
||||
@old_siginfo = nil
|
||||
@options = nil
|
||||
@stats = nil
|
||||
@current = nil
|
||||
@exclude = nil
|
||||
@generator = nil
|
||||
@last_modified = {}
|
||||
@old_siginfo = nil
|
||||
@options = nil
|
||||
@stats = nil
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -132,35 +137,39 @@ class RDoc::RDoc
|
|||
# contain the flag file <tt>created.rid</tt> then we refuse to use it, as
|
||||
# we may clobber some manually generated documentation
|
||||
|
||||
def setup_output_dir(op_dir, force)
|
||||
flag_file = output_flag_file op_dir
|
||||
def setup_output_dir(dir, force)
|
||||
flag_file = output_flag_file dir
|
||||
|
||||
last = {}
|
||||
|
||||
if File.exist? op_dir then
|
||||
unless File.directory? op_dir then
|
||||
error "'#{op_dir}' exists, and is not a directory"
|
||||
end
|
||||
if File.exist? dir then
|
||||
error "#{dir} exists and is not a directory" unless File.directory? dir
|
||||
|
||||
begin
|
||||
open flag_file do |io|
|
||||
unless force
|
||||
unless force then
|
||||
Time.parse io.gets
|
||||
|
||||
io.each do |line|
|
||||
file, time = line.split(/\t/, 2)
|
||||
file, time = line.split "\t", 2
|
||||
time = Time.parse(time) rescue next
|
||||
last[file] = time
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue
|
||||
error "\nDirectory #{op_dir} already exists, but it looks like it\n" +
|
||||
"isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
|
||||
"destroying any of your existing files, you'll need to\n" +
|
||||
"specify a different output directory name (using the\n" +
|
||||
"--op <dir> option).\n\n"
|
||||
rescue SystemCallError, TypeError
|
||||
error <<-ERROR
|
||||
|
||||
Directory #{dir} already exists, but it looks like it isn't an RDoc directory.
|
||||
|
||||
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
|
||||
else
|
||||
FileUtils.mkdir_p(op_dir)
|
||||
FileUtils.mkdir_p dir
|
||||
end
|
||||
|
||||
last
|
||||
|
@ -170,7 +179,7 @@ class RDoc::RDoc
|
|||
# Update the flag file in an output directory.
|
||||
|
||||
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
|
||||
last.each do |n, t|
|
||||
f.puts "#{n}\t#{t.rfc2822}"
|
||||
|
@ -226,12 +235,12 @@ class RDoc::RDoc
|
|||
|
||||
case type = stat.ftype
|
||||
when "file" then
|
||||
next if last_created = @last_created[rel_file_name] and
|
||||
stat.mtime.to_i <= last_created.to_i
|
||||
next if last_modified = @last_modified[rel_file_name] and
|
||||
stat.mtime.to_i <= last_modified.to_i
|
||||
|
||||
if force_doc or RDoc::Parser.can_parse(rel_file_name) then
|
||||
file_list << rel_file_name.sub(/^\.\//, '')
|
||||
@last_created[rel_file_name] = stat.mtime
|
||||
@last_modified[rel_file_name] = stat.mtime
|
||||
end
|
||||
when "directory" then
|
||||
next if rel_file_name == "CVS" || rel_file_name == ".svn"
|
||||
|
@ -356,7 +365,7 @@ The internal error was:
|
|||
|
||||
@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
|
||||
|
||||
|
@ -382,7 +391,7 @@ The internal error was:
|
|||
self.class.current = self
|
||||
|
||||
@generator.generate file_info
|
||||
update_output_dir ".", start_time, @last_created
|
||||
update_output_dir ".", start_time, @last_modified
|
||||
ensure
|
||||
self.class.current = nil
|
||||
end
|
||||
|
@ -396,7 +405,7 @@ The internal error was:
|
|||
end
|
||||
|
||||
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 /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.*\n)?.*\n"]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'tempfile'
|
||||
require 'tmpdir'
|
||||
require 'rubygems'
|
||||
require 'minitest/autorun'
|
||||
require 'rdoc/rdoc'
|
||||
|
@ -11,7 +12,7 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
|
|||
end
|
||||
|
||||
def teardown
|
||||
@tempfile.close
|
||||
@tempfile.close rescue nil # HACK for 1.8.6
|
||||
end
|
||||
|
||||
def test_gather_files
|
||||
|
@ -19,6 +20,24 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
|
|||
assert_equal [file], @rdoc.gather_files([file, file])
|
||||
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
|
||||
@tempfile.write "hi everybody"
|
||||
@tempfile.flush
|
||||
|
@ -62,5 +81,75 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
|
|||
assert_empty @rdoc.remove_unparseable file_list
|
||||
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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче