From 8e94bb29ae5c33d988cba29f130ba0d0a7276b00 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 30 Aug 2004 14:22:26 +0000 Subject: 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 --- ChangeLog | 5 +++++ bin/ri | 27 +++++++++++++++++++++++++++ lib/rdoc/markup/simple_markup/fragments.rb | 2 +- lib/rdoc/markup/simple_markup/to_flow.rb | 13 ++++++------- lib/rdoc/ri/ri_cache.rb | 19 +++++++++++++++---- lib/rdoc/ri/ri_descriptions.rb | 4 ++++ lib/rdoc/ri/ri_driver.rb | 26 ++++++++++++++++---------- lib/rdoc/ri/ri_options.rb | 8 +++++++- lib/rdoc/ri/ri_reader.rb | 13 +++++++++++-- 9 files changed, 92 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index de866bdc58..e98760354d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Aug 30 23:11:06 2004 Dave Thomas + + * 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 * ext/tk/lib/multi-tk.rb: 'restart' method accepts arguments diff --git a/bin/ri b/bin/ri index 1f5e6a5ff3..fb3e00eda3 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. +# +# If you installed Ruby from source files (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 +# /usr/local. +# +# If you installed Ruby from a binary distribution (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 83388fcc0b..6ca06382ab 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 4718cfaaf6..401703a72a 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 => [ "
    ", "
" ], - ListBase::NUMBER => [ "
    ", "
" ], - ListBase::UPPERALPHA => [ "
    ", "
" ], - ListBase::LOWERALPHA => [ "
    ", "
" ], - ListBase::LABELED => [ "
", "
" ], - ListBase::NOTE => [ "", "
" ], + SM::ListBase::BULLET => [ "
    ", "
" ], + SM::ListBase::NUMBER => [ "
    ", "
" ], + SM::ListBase::UPPERALPHA => [ "
    ", "
" ], + SM::ListBase::LOWERALPHA => [ "
    ", "
" ], + SM::ListBase::LABELED => [ "
", "
" ], + SM::ListBase::NOTE => [ "", "
" ], } InlineTag = Struct.new(:bit, :on, :off) diff --git a/lib/rdoc/ri/ri_cache.rb b/lib/rdoc/ri/ri_cache.rb index 189817485b..1844ac969e 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 96041f1c7e..316fc91903 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 35c20a7a1a..d2545bb1da 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 ba420344f3..f59cdeda1c 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 6e53bd2609..fb2c373e38 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 -- cgit v1.2.3