summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-30 14:22:26 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-30 14:22:26 +0000
commit8e94bb29ae5c33d988cba29f130ba0d0a7276b00 (patch)
tree17f3eb310a24fabe871f4f407bd2b98f6ccb270c
parente80e14c7882d3955eb88d078f43822af030a1bf4 (diff)
ri now merges the documentation if it finds the same class in multiple places
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rwxr-xr-xbin/ri27
-rw-r--r--lib/rdoc/markup/simple_markup/fragments.rb2
-rw-r--r--lib/rdoc/markup/simple_markup/to_flow.rb13
-rw-r--r--lib/rdoc/ri/ri_cache.rb19
-rw-r--r--lib/rdoc/ri/ri_descriptions.rb4
-rw-r--r--lib/rdoc/ri/ri_driver.rb26
-rw-r--r--lib/rdoc/ri/ri_options.rb8
-rw-r--r--lib/rdoc/ri/ri_reader.rb13
9 files changed, 92 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index de866bd..e987603 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Aug 30 23:11:06 2004 Dave Thomas <dave@pragprog.com>
+
+ * lib/rdoc/ri/ri_driver.rb (and others): ri now merges documentation
+ if it finds the same class in multiple places.
+
Mon Aug 30 22:40:30 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: 'restart' method accepts arguments
diff --git a/bin/ri b/bin/ri
index 1f5e6a5..fb3e00e 100755
--- a/bin/ri
+++ b/bin/ri
@@ -12,6 +12,33 @@
#
# The form '.' method matches either class or instance methods, while
# #method matches only instance and ::method matches only class methods.
+#
+#
+# == Installing Documentation
+#
+# 'ri' uses a database of documentation built by the RDoc utility.
+#
+# So, how do you install this documentation on your system?
+# It depends on how you installed Ruby.
+#
+# <em>If you installed Ruby from source files</em> (that is, if it some point
+# you typed 'make' during the process :), you can install the RDoc
+# documentation yourself. Just go back to the place where you have
+# your Ruby source and type
+#
+# make install-doc
+#
+# You'll probably need to do this as a superuser, as the documentation
+# is installed in the Ruby target tree (normally somewhere under
+# <tt>/usr/local</tt>.
+#
+# <em>If you installed Ruby from a binary distribution</em> (perhaps
+# using a one-click installer, or using some other packaging system),
+# then the team that produced the package probably forgot to package
+# the documentation as well. Contact them, and see if they can add
+# it to the next release.
+#
+
require 'rdoc/ri/ri_driver'
diff --git a/lib/rdoc/markup/simple_markup/fragments.rb b/lib/rdoc/markup/simple_markup/fragments.rb
index 83388fc..6ca0638 100644
--- a/lib/rdoc/markup/simple_markup/fragments.rb
+++ b/lib/rdoc/markup/simple_markup/fragments.rb
@@ -1,5 +1,5 @@
require 'rdoc/markup/simple_markup/lines.rb'
-require 'rdoc/markup/simple_markup/inline.rb'
+#require 'rdoc/markup/simple_markup/to_flow.rb'
module SM
diff --git a/lib/rdoc/markup/simple_markup/to_flow.rb b/lib/rdoc/markup/simple_markup/to_flow.rb
index 4718cfa..401703a 100644
--- a/lib/rdoc/markup/simple_markup/to_flow.rb
+++ b/lib/rdoc/markup/simple_markup/to_flow.rb
@@ -23,14 +23,13 @@ module SM
end
class ToFlow
-
LIST_TYPE_TO_HTML = {
- ListBase::BULLET => [ "<ul>", "</ul>" ],
- ListBase::NUMBER => [ "<ol>", "</ol>" ],
- ListBase::UPPERALPHA => [ "<ol>", "</ol>" ],
- ListBase::LOWERALPHA => [ "<ol>", "</ol>" ],
- ListBase::LABELED => [ "<dl>", "</dl>" ],
- ListBase::NOTE => [ "<table>", "</table>" ],
+ SM::ListBase::BULLET => [ "<ul>", "</ul>" ],
+ SM::ListBase::NUMBER => [ "<ol>", "</ol>" ],
+ SM::ListBase::UPPERALPHA => [ "<ol>", "</ol>" ],
+ SM::ListBase::LOWERALPHA => [ "<ol>", "</ol>" ],
+ SM::ListBase::LABELED => [ "<dl>", "</dl>" ],
+ SM::ListBase::NOTE => [ "<table>", "</table>" ],
}
InlineTag = Struct.new(:bit, :on, :off)
diff --git a/lib/rdoc/ri/ri_cache.rb b/lib/rdoc/ri/ri_cache.rb
index 1898174..1844ac9 100644
--- a/lib/rdoc/ri/ri_cache.rb
+++ b/lib/rdoc/ri/ri_cache.rb
@@ -3,10 +3,10 @@ module RI
class ClassEntry
attr_reader :name
- attr_reader :path_name
+ attr_reader :path_names
def initialize(path_name, name, in_class)
- @path_name = path_name
+ @path_names = [ path_name ]
@name = name
@in_class = in_class
@class_methods = []
@@ -14,6 +14,12 @@ module RI
@inferior_classes = []
end
+ # We found this class in more tha one place, so add
+ # in the name from there.
+ def add_path(path)
+ @path_names << path
+ end
+
# read in our methods and any classes
# and modules in our namespace. Methods are
# stored in files called name-c|i.yaml,
@@ -38,9 +44,14 @@ module RI
else
full_name = File.join(dir, name)
if File.directory?(full_name)
- inf_class = ClassEntry.new(full_name, name, self)
+ inf_class = @inferior_classes.find {|c| c.name == name }
+ if inf_class
+ inf_class.add_path(full_name)
+ else
+ inf_class = ClassEntry.new(full_name, name, self)
+ @inferior_classes << inf_class
+ end
inf_class.load_from(full_name)
- @inferior_classes << inf_class
end
end
end
diff --git a/lib/rdoc/ri/ri_descriptions.rb b/lib/rdoc/ri/ri_descriptions.rb
index 96041f1..316fc91 100644
--- a/lib/rdoc/ri/ri_descriptions.rb
+++ b/lib/rdoc/ri/ri_descriptions.rb
@@ -1,4 +1,5 @@
require 'yaml'
+require 'rdoc/markup/simple_markup/fragments'
# Descriptions are created by RDoc (in ri_generator) and
# written out in serialized form into the documentation
@@ -93,6 +94,9 @@ module RI
merge(@includes, old.includes)
if @comment.nil? || @comment.empty?
@comment = old.comment
+ else
+ @comment << SM::Flow::RULE.new
+ @comment.concat old.comment
end
end
diff --git a/lib/rdoc/ri/ri_driver.rb b/lib/rdoc/ri/ri_driver.rb
index 35c20a7..d2545bb 100644
--- a/lib/rdoc/ri/ri_driver.rb
+++ b/lib/rdoc/ri/ri_driver.rb
@@ -1,3 +1,4 @@
+require 'rdoc/usage'
require 'rdoc/ri/ri_paths'
require 'rdoc/ri/ri_cache'
require 'rdoc/ri/ri_util'
@@ -22,18 +23,23 @@ class RiDriver
paths = @options.paths || RI::Paths::PATH
if paths.empty?
- $stderr.puts "No ri documentation found in:"
- [ RI::Paths::SYSDIR, RI::Paths::SITEDIR, RI::Paths::HOMEDIR].each do |d|
- $stderr.puts " #{d}"
- end
- $stderr.puts "\nWas rdoc run to create documentation?"
- exit 1
+ report_missing_documentation(paths)
end
@ri_reader = RI::RiReader.new(RI::RiCache.new(paths))
@display = @options.displayer
end
-
+ # Couldn't find documentation in paths, so tell the user
+ # what to do
+
+ def report_missing_documentation(paths)
+ STDERR.puts "No ri documentation found in:"
+ paths.each do |d|
+ STDERR.puts " #{d}"
+ end
+ STDERR.puts "\nWas rdoc run to create documentation?\n\n"
+ RDoc::usage("Installing Documentation")
+ end
######################################################################
@@ -79,7 +85,7 @@ class RiDriver
def get_info_for(arg)
desc = NameDescriptor.new(arg)
-
+
namespaces = @ri_reader.top_level_namespace
for class_name in desc.class_names
@@ -102,7 +108,7 @@ class RiDriver
methods = @ri_reader.find_methods(desc.method_name,
desc.is_class_method,
namespaces)
-
+
if methods.empty?
raise RiError.new("Nothing known about #{arg}")
else
@@ -129,7 +135,7 @@ class RiDriver
get_info_for(arg)
end
rescue RiError => e
- $stderr.puts(e.message)
+ STDERR.puts(e.message)
exit(1)
end
end
diff --git a/lib/rdoc/ri/ri_options.rb b/lib/rdoc/ri/ri_options.rb
index ba42034..f59cded 100644
--- a/lib/rdoc/ri/ri_options.rb
+++ b/lib/rdoc/ri/ri_options.rb
@@ -208,7 +208,13 @@ module RI
when "--list-names" then @list_names = true
when "--no-pager" then @use_stdout = true
when "--classes" then @list_classes = true
- when "--doc-dir" then @doc_dir = arg
+ when "--doc-dir"
+ if File.directory?(arg)
+ @doc_dir = arg
+ else
+ $stderr.puts "Invalid directory: #{arg}"
+ exit 1
+ end
when "--format"
@formatter = RI::TextFormatter.for(arg)
diff --git a/lib/rdoc/ri/ri_reader.rb b/lib/rdoc/ri/ri_reader.rb
index 6e53bd2..fb2c373 100644
--- a/lib/rdoc/ri/ri_reader.rb
+++ b/lib/rdoc/ri/ri_reader.rb
@@ -48,8 +48,17 @@ module RI
# Return a class description
def get_class(class_entry)
- path = RiWriter.class_desc_path(class_entry.path_name, class_entry)
- File.open(path) {|f| RI::Description.deserialize(f) }
+ result = nil
+ for path in class_entry.path_names
+ path = RiWriter.class_desc_path(path, class_entry)
+ desc = File.open(path) {|f| RI::Description.deserialize(f) }
+ if result
+ result.merge_in(desc)
+ else
+ result = desc
+ end
+ end
+ result
end
# return the names of all classes and modules