aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-14 05:09:37 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-14 05:09:37 +0000
commit1dfe3d93fa5d9ddabae8db067c5705ea6e551442 (patch)
treef5d79304d50c36811dd97167236e01c69b8cfb5e /lib
parent497f8904cb3f90a3abf5340a129811aceb96ee33 (diff)
downloadruby-1dfe3d93fa5d9ddabae8db067c5705ea6e551442.tar.gz
* 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
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/commands/rdoc_command.rb6
-rw-r--r--lib/rubygems/rdoc.rb91
-rw-r--r--lib/rubygems/server.rb9
3 files changed, 63 insertions, 43 deletions
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index 9bb07245cd..df00f3a5df 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -1,6 +1,7 @@
require 'rubygems/command'
require 'rubygems/version_option'
require 'rubygems/rdoc'
+require 'fileutils'
class Gem::Commands::RdocCommand < Gem::Command
include Gem::VersionOption
@@ -72,6 +73,11 @@ The rdoc command builds RDoc and RI documentation for installed gems. Use
doc.force = options[:overwrite]
+ if options[:overwrite] then
+ FileUtils.rm_rf File.join(spec.doc_dir, 'ri')
+ FileUtils.rm_rf File.join(spec.doc_dir, 'rdoc')
+ end
+
begin
doc.generate
rescue Errno::ENOENT => e
diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb
index 65414462fa..15ccc3e455 100644
--- a/lib/rubygems/rdoc.rb
+++ b/lib/rubygems/rdoc.rb
@@ -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
+ generator = options.generator.new @rdoc.store, options
+
@rdoc.options = options
- @rdoc.generator = options.generator.new options
+ @rdoc.generator = generator
- say "Installing #{generator} documentation for #{@spec.full_name}"
+ 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
- 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)
+ ::RDoc::TopLevel.reset # TODO ::RDoc::RDoc.reset
+ ::RDoc::Parser::C.reset
- args = @spec.rdoc_options
+ 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
+ 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
- delete_legacy_args args
+ Dir.chdir @spec.full_gem_path do
+ options = ::RDoc::Options.new
+ options.default_title = "#{@spec.full_name} Documentation"
options.parse args
- options.quiet = !Gem.configuration.really_verbose
+ end
- @rdoc = new_rdoc
- @rdoc.options = options
+ options.quiet = !Gem.configuration.really_verbose
- Dir.chdir @spec.full_gem_path do
- @file_info = @rdoc.parse_files options.files
- end
+ @rdoc = new_rdoc
+ @rdoc.options = options
- document 'ri', options, @ri_dir if
- @generate_ri and (@force or not File.exist? @ri_dir)
+ say "Parsing documentation for #{@spec.full_name}"
- document 'darkfish', options, @rdoc_dir if
- @generate_rdoc and (@force or not File.exist? @rdoc_dir)
+ 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
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
index b640186b64..dd582193ee 100644
--- a/lib/rubygems/server.rb
+++ b/lib/rubygems/server.rb
@@ -79,7 +79,9 @@ class Gem::Server
<b><%=spec["name"]%> <%=spec["version"]%></b>
- <% if spec["rdoc_installed"] then %>
+ <% if spec["ri_installed"] then %>
+ <a href="<%=spec["doc_path"]%>">[rdoc]</a>
+ <% elsif spec["rdoc_installed"] then %>
<a href="<%=spec["doc_path"]%>">[rdoc]</a>
<% else %>
<span title="rdoc not installed">[rdoc]</span>
@@ -464,7 +466,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
def have_rdoc_4_plus?
@have_rdoc_4_plus ||=
- Gem::Requirement.new('>= 4').satisfied_by? Gem::RDoc.rdoc_version
+ Gem::Requirement.new('>= 4.0.0.preview2').satisfied_by? Gem::RDoc.rdoc_version
end
def latest_specs(req, res)
@@ -604,6 +606,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
"homepage" => spec.homepage,
"name" => spec.name,
"rdoc_installed" => Gem::RDoc.new(spec).rdoc_installed?,
+ "ri_installed" => Gem::RDoc.new(spec).ri_installed?,
"summary" => spec.summary,
"version" => spec.version.to_s,
}
@@ -619,7 +622,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
"has_deps" => false,
"homepage" => "http://docs.rubygems.org/",
"name" => 'rubygems',
- "rdoc_installed" => true,
+ "ri_installed" => true,
"summary" => "RubyGems itself",
"version" => Gem::VERSION,
}