diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 06:52:18 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 06:52:18 +0000 |
commit | 9694bb8cac12969300692dac5a1cf7aa4e3a46cd (patch) | |
tree | c3cb423d701f7049ba9382de052e2a937cd1302d /lib/rubygems/commands/rdoc_command.rb | |
parent | 3f606b7063fc7a8b191556365ad343a314719a8d (diff) | |
download | ruby-9694bb8cac12969300692dac5a1cf7aa4e3a46cd.tar.gz |
* lib/rubygems*: Updated to RubyGems 2.0
* test/rubygems*: ditto.
* common.mk (prelude): Updated for RubyGems 2.0 source rearrangement.
* tool/change_maker.rb: Allow invalid UTF-8 characters in source
files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/rdoc_command.rb')
-rw-r--r-- | lib/rubygems/commands/rdoc_command.rb | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb index ea0f3ad592..9bb07245cd 100644 --- a/lib/rubygems/commands/rdoc_command.rb +++ b/lib/rubygems/commands/rdoc_command.rb @@ -1,6 +1,6 @@ require 'rubygems/command' require 'rubygems/version_option' -require 'rubygems/doc_manager' +require 'rubygems/rdoc' class Gem::Commands::RdocCommand < Gem::Command include Gem::VersionOption @@ -8,7 +8,7 @@ class Gem::Commands::RdocCommand < Gem::Command def initialize super 'rdoc', 'Generates RDoc for pre-installed gems', :version => Gem::Requirement.default, - :include_rdoc => true, :include_ri => true, :overwrite => false + :include_rdoc => false, :include_ri => true, :overwrite => false add_option('--all', 'Generate RDoc/RI documentation for all', @@ -39,7 +39,7 @@ class Gem::Commands::RdocCommand < Gem::Command end def defaults_str # :nodoc: - "--version '#{Gem::Requirement.default}' --rdoc --ri --no-overwrite" + "--version '#{Gem::Requirement.default}' --ri --no-overwrite" end def description # :nodoc: @@ -54,37 +54,32 @@ The rdoc command builds RDoc and RI documentation for installed gems. Use end def execute - if options[:all] then - specs = Gem::SourceIndex.from_installed_gems.collect { |name, spec| - spec - } - else - gem_name = get_one_gem_name - dep = Gem::Dependency.new gem_name, options[:version] - specs = Gem::SourceIndex.from_installed_gems.search dep + specs = if options[:all] then + Gem::Specification.to_a + else + get_all_gem_names.map do |name| + Gem::Specification.find_by_name name, options[:version] + end.flatten.uniq + end + + if specs.empty? then + alert_error 'No matching gems found' + terminate_interaction 1 end - if specs.empty? - raise "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}" - end + specs.each do |spec| + doc = Gem::RDoc.new spec, options[:include_rdoc], options[:include_ri] - if options[:include_ri] - specs.sort.each do |spec| - doc = Gem::DocManager.new(spec) - doc.generate_ri if options[:overwrite] || !doc.ri_installed? - end + doc.force = options[:overwrite] - Gem::DocManager.update_ri_cache - end - - if options[:include_rdoc] - specs.sort.each do |spec| - doc = Gem::DocManager.new(spec) - doc.generate_rdoc if options[:overwrite] || !doc.rdoc_installed? + begin + doc.generate + rescue Errno::ENOENT => e + e.message =~ / - / + alert_error "Unable to document #{spec.full_name}, #{$'} is missing, skipping" + terminate_interaction 1 if specs.length == 1 end end - - true end end |