mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rubygems/commands/rdoc_command.rb: When overwriting
documentation, remove existing documentation first. * lib/rubygems/server.rb: Fixed documentation links. * test/rubygems/test_gem_server.rb: Test for the above. * lib/rubygems/rdoc.rb: Reduced diff with RDoc::RubyGemsHook * test/rubygems/test_gem_rdoc.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
497f8904cb
commit
1dfe3d93fa
6 changed files with 145 additions and 95 deletions
|
@ -86,18 +86,16 @@ class Gem::RDoc # :nodoc: all
|
|||
def self.load_rdoc
|
||||
return if @rdoc_version
|
||||
|
||||
begin
|
||||
require 'rdoc/rdoc'
|
||||
require 'rdoc/rdoc'
|
||||
|
||||
@rdoc_version = if ::RDoc.const_defined? :VERSION then
|
||||
Gem::Version.new ::RDoc::VERSION
|
||||
else
|
||||
Gem::Version.new '1.0.1'
|
||||
end
|
||||
@rdoc_version = if ::RDoc.const_defined? :VERSION then
|
||||
Gem::Version.new ::RDoc::VERSION
|
||||
else
|
||||
Gem::Version.new '1.0.1'
|
||||
end
|
||||
|
||||
rescue LoadError => e
|
||||
raise Gem::DocumentError, "RDoc is not installed: #{e}"
|
||||
end
|
||||
rescue LoadError => e
|
||||
raise Gem::DocumentError, "RDoc is not installed: #{e}"
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -107,7 +105,7 @@ class Gem::RDoc # :nodoc: all
|
|||
#
|
||||
# Only +generate_ri+ is enabled by default.
|
||||
|
||||
def initialize spec, generate_rdoc = false, generate_ri = true
|
||||
def initialize spec, generate_rdoc = true, generate_ri = true
|
||||
@doc_dir = spec.doc_dir
|
||||
@file_info = nil
|
||||
@force = false
|
||||
|
@ -123,6 +121,8 @@ class Gem::RDoc # :nodoc: all
|
|||
|
||||
##
|
||||
# Removes legacy rdoc arguments from +args+
|
||||
#--
|
||||
# TODO move to RDoc::Options
|
||||
|
||||
def delete_legacy_args args
|
||||
args.delete '--inline-source'
|
||||
|
@ -138,16 +138,20 @@ class Gem::RDoc # :nodoc: all
|
|||
# Documentation will be generated into +destination+
|
||||
|
||||
def document generator, options, destination
|
||||
generator_name = generator
|
||||
|
||||
options = options.dup
|
||||
options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
|
||||
options.setup_generator generator
|
||||
options.op_dir = destination
|
||||
options.finish
|
||||
|
||||
@rdoc.options = options
|
||||
@rdoc.generator = options.generator.new options
|
||||
generator = options.generator.new @rdoc.store, options
|
||||
|
||||
say "Installing #{generator} documentation for #{@spec.full_name}"
|
||||
@rdoc.options = options
|
||||
@rdoc.generator = generator
|
||||
|
||||
say "Installing #{generator_name} documentation for #{@spec.full_name}"
|
||||
|
||||
FileUtils.mkdir_p options.op_dir
|
||||
|
||||
|
@ -169,44 +173,51 @@ class Gem::RDoc # :nodoc: all
|
|||
|
||||
setup
|
||||
|
||||
options = nil
|
||||
|
||||
if Gem::Requirement.new('< 3').satisfied_by? self.class.rdoc_version then
|
||||
generate_legacy
|
||||
else
|
||||
::RDoc::TopLevel.reset # TODO ::RDoc::RDoc.reset
|
||||
::RDoc::Parser::C.reset
|
||||
return
|
||||
end
|
||||
|
||||
::RDoc::TopLevel.reset # TODO ::RDoc::RDoc.reset
|
||||
::RDoc::Parser::C.reset
|
||||
|
||||
args = @spec.rdoc_options
|
||||
args.concat @spec.require_paths
|
||||
args.concat @spec.extra_rdoc_files
|
||||
|
||||
case config_args = Gem.configuration[:rdoc]
|
||||
when String then
|
||||
args = args.concat config_args.split
|
||||
when Array then
|
||||
args = args.concat config_args
|
||||
end
|
||||
|
||||
delete_legacy_args args
|
||||
|
||||
Dir.chdir @spec.full_gem_path do
|
||||
options = ::RDoc::Options.new
|
||||
options.default_title = "#{@spec.full_name} Documentation"
|
||||
options.files = []
|
||||
options.files.push(*@spec.require_paths)
|
||||
options.files.push(*@spec.extra_rdoc_files)
|
||||
|
||||
args = @spec.rdoc_options
|
||||
|
||||
case config_args = Gem.configuration[:rdoc]
|
||||
when String then
|
||||
args = args.concat config_args.split
|
||||
when Array then
|
||||
args = args.concat config_args
|
||||
end
|
||||
|
||||
delete_legacy_args args
|
||||
options.parse args
|
||||
options.quiet = !Gem.configuration.really_verbose
|
||||
|
||||
@rdoc = new_rdoc
|
||||
@rdoc.options = options
|
||||
|
||||
Dir.chdir @spec.full_gem_path do
|
||||
@file_info = @rdoc.parse_files options.files
|
||||
end
|
||||
|
||||
document 'ri', options, @ri_dir if
|
||||
@generate_ri and (@force or not File.exist? @ri_dir)
|
||||
|
||||
document 'darkfish', options, @rdoc_dir if
|
||||
@generate_rdoc and (@force or not File.exist? @rdoc_dir)
|
||||
end
|
||||
|
||||
options.quiet = !Gem.configuration.really_verbose
|
||||
|
||||
@rdoc = new_rdoc
|
||||
@rdoc.options = options
|
||||
|
||||
say "Parsing documentation for #{@spec.full_name}"
|
||||
|
||||
Dir.chdir @spec.full_gem_path do
|
||||
@file_info = @rdoc.parse_files options.files
|
||||
end
|
||||
|
||||
document 'ri', options, @ri_dir if
|
||||
@generate_ri and (@force or not File.exist? @ri_dir)
|
||||
|
||||
document 'darkfish', options, @rdoc_dir if
|
||||
@generate_rdoc and (@force or not File.exist? @rdoc_dir)
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -268,7 +279,7 @@ class Gem::RDoc # :nodoc: all
|
|||
# #new_rdoc creates a new RDoc instance. This method is provided only to
|
||||
# make testing easier.
|
||||
|
||||
def new_rdoc
|
||||
def new_rdoc # :nodoc:
|
||||
::RDoc::RDoc.new
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue