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

* lib/rdoc/rubygems_hook.rb: Fixed generation of documentation.

Disabled rdoc generation by default to match RubyGems defaults.
  Reduced diff with RubyGems::RDoc.
* test/rdoc/test_rdoc_rubygems_hook.rb:  Tests for the above.
* test/rubygems/test_gem_rdoc.rb:  ditto.

* lib/rdoc/store.rb:  Removed useless variable assignment


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2012-12-14 05:16:56 +00:00
parent 1dfe3d93fa
commit 8adec52962
5 changed files with 75 additions and 28 deletions

View file

@ -1,3 +1,13 @@
Fri Dec 14 14:16:42 2012 Eric Hodel <drbrain@segment7.net>
* lib/rdoc/rubygems_hook.rb: Fixed generation of documentation.
Disabled rdoc generation by default to match RubyGems defaults.
Reduced diff with RubyGems::RDoc.
* test/rdoc/test_rdoc_rubygems_hook.rb: Tests for the above.
* test/rubygems/test_gem_rdoc.rb: ditto.
* lib/rdoc/store.rb: Removed useless variable assignment
Fri Dec 14 13:58:40 2012 Eric Hodel <drbrain@segment7.net>
* lib/rubygems/commands/rdoc_command.rb: When overwriting

View file

@ -68,10 +68,12 @@ class RDoc::RubygemsHook
##
# Creates a new documentation generator for +spec+. RDoc and ri data
# generation can be disabled through +generate_rdoc+ and +generate_ri+
# respectively.
# generation can be enabled or disabled through +generate_rdoc+ and
# +generate_ri+ respectively.
#
# Only +generate_ri+ is enabled by default.
def initialize spec, generate_rdoc = true, generate_ri = true
def initialize spec, generate_rdoc = false, generate_ri = true
@doc_dir = spec.doc_dir
@force = false
@rdoc = nil
@ -139,13 +141,11 @@ class RDoc::RubygemsHook
setup
options = ::RDoc::Options.new
options.default_title = "#{@spec.full_name} Documentation"
options.files = []
options.files.concat @spec.require_paths
options.files.concat @spec.extra_rdoc_files
options = nil
args = @spec.rdoc_options
args.concat @spec.require_paths
args.concat @spec.extra_rdoc_files
case config_args = Gem.configuration[:rdoc]
when String then
@ -155,7 +155,13 @@ class RDoc::RubygemsHook
end
delete_legacy_args args
options.parse args
Dir.chdir @spec.full_gem_path do
options = ::RDoc::Options.new
options.default_title = "#{@spec.full_name} Documentation"
options.parse args
end
options.quiet = !Gem.configuration.really_verbose
@rdoc = new_rdoc
@ -167,7 +173,7 @@ class RDoc::RubygemsHook
store.main = options.main_page
store.title = options.title
@rdoc.store = RDoc::Store.new
@rdoc.store = store
say "Parsing documentation for #{@spec.full_name}"

View file

@ -596,7 +596,7 @@ class RDoc::Store
def load_class_data klass_name
file = class_file klass_name
obj = open file, 'rb' do |io|
open file, 'rb' do |io|
Marshal.load io.read
end
rescue Errno::ENOENT => e

View file

@ -10,7 +10,15 @@ class TestRDocRubygemsHook < Gem::TestCase
skip 'requires RubyGems 1.9+' unless
Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.9')
@a = quick_spec 'a'
@a = quick_spec 'a' do |s|
s.rdoc_options = %w[--main MyTitle]
s.extra_rdoc_files = %w[README]
end
write_file File.join(@tempdir, 'lib', 'a.rb')
write_file File.join(@tempdir, 'README')
install_gem @a
@hook = RDoc::RubygemsHook.new @a
@ -24,7 +32,7 @@ class TestRDocRubygemsHook < Gem::TestCase
end
def test_initialize
assert @hook.generate_rdoc
refute @hook.generate_rdoc
assert @hook.generate_ri
rdoc = RDoc::RubygemsHook.new @a, false, false
@ -66,12 +74,37 @@ class TestRDocRubygemsHook < Gem::TestCase
@hook.generate
refute @hook.rdoc_installed?
assert @hook.ri_installed?
rdoc = @hook.instance_variable_get :@rdoc
refute rdoc.options.hyperlink_all
assert_equal Pathname(@a.full_gem_path), rdoc.options.root
assert_equal %w[README lib], rdoc.options.files.sort
assert_equal 'MyTitle', rdoc.store.main
end
def test_generate_all
@hook.generate_rdoc = true
@hook.generate_ri = true
FileUtils.mkdir_p @a.doc_dir
FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
@hook.generate
assert @hook.rdoc_installed?
assert @hook.ri_installed?
rdoc = @hook.instance_variable_get :@rdoc
refute rdoc.options.hyperlink_all
assert_equal Pathname(@a.full_gem_path), rdoc.options.root
assert_equal %w[README lib], rdoc.options.files.sort
assert_equal 'MyTitle', rdoc.store.main
end
def test_generate_configuration_rdoc_array
@ -133,7 +166,7 @@ class TestRDocRubygemsHook < Gem::TestCase
@hook.generate
assert_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
end
@ -183,7 +216,7 @@ class TestRDocRubygemsHook < Gem::TestCase
assert_equal @a.base_dir, e.directory
ensure
FileUtils.chmod 0755, @a.base_dir
FileUtils.chmod(0755, @a.base_dir) if File.directory?(@a.base_dir)
end
def test_ri_installed?
@ -202,20 +235,18 @@ class TestRDocRubygemsHook < Gem::TestCase
def test_setup_unwritable
skip 'chmod not supported' if Gem.win_platform?
begin
FileUtils.mkdir_p @a.doc_dir
FileUtils.chmod 0, @a.doc_dir
FileUtils.mkdir_p @a.doc_dir
FileUtils.chmod 0, @a.doc_dir
e = assert_raises Gem::FilePermissionError do
@hook.setup
end
e = assert_raises Gem::FilePermissionError do
@hook.setup
end
assert_equal @a.doc_dir, e.directory
ensure
if File.exist? @a.doc_dir
FileUtils.chmod 0755, @a.doc_dir
FileUtils.rm_r @a.doc_dir
end
assert_equal @a.doc_dir, e.directory
ensure
if File.exist? @a.doc_dir
FileUtils.chmod 0755, @a.doc_dir
FileUtils.rm_r @a.doc_dir
end
end

View file

@ -43,7 +43,7 @@ class TestGemRDoc < Gem::TestCase
end
def test_initialize
assert @hook.generate_rdoc
refute @hook.generate_rdoc
assert @hook.generate_ri
rdoc = Gem::RDoc.new @a, false, false