diff --git a/lib/rdoc/rubygems_hook.rb b/lib/rdoc/rubygems_hook.rb index 90cb37f86d..a1216d346d 100644 --- a/lib/rdoc/rubygems_hook.rb +++ b/lib/rdoc/rubygems_hook.rb @@ -182,18 +182,21 @@ def generate options.default_title = "#{@spec.full_name} Documentation" options.parse args options.quiet = !Gem.configuration.really_verbose - options.finish end @rdoc = new_rdoc - @rdoc.options = options - - @rdoc.store = RDoc::Store.new(options) say "Parsing documentation for #{@spec.full_name}" Dir.chdir @spec.full_gem_path do - @rdoc.parse_files options.files + # RDoc::Options#finish must be called before parse_files. + # RDoc::Options#finish is also called after ri/darkfish generator setup. + # We need to dup the options to avoid modifying it after finish is called. + parse_options = options.dup + parse_options.finish + @rdoc.options = parse_options + @rdoc.store = RDoc::Store.new(parse_options) + @rdoc.parse_files parse_options.files end document 'ri', options, @ri_dir if diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb index ccb86c2a2c..29488e7ac1 100644 --- a/test/rdoc/test_rdoc_rubygems_hook.rb +++ b/test/rdoc/test_rdoc_rubygems_hook.rb @@ -241,6 +241,18 @@ def test_generate_no_overwrite assert_path_not_exist File.join(@a.doc_dir('ri'), 'cache.ri') end + def test_generate_with_ri_opt + @a.rdoc_options << '--ri' + FileUtils.mkdir_p @a.doc_dir + FileUtils.mkdir_p File.join(@a.gem_dir, 'lib') + @hook.generate_rdoc = true + @hook.generate_ri = true + @hook.generate + + assert_path_exist File.join(@a.doc_dir('rdoc'), 'index.html') + assert_path_exist File.join(@a.doc_dir('ri'), 'cache.ri') + end + def test_new_rdoc assert_kind_of RDoc::RDoc, @hook.new_rdoc end