diff options
author | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-30 14:22:26 +0000 |
---|---|---|
committer | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-30 14:22:26 +0000 |
commit | 8e94bb29ae5c33d988cba29f130ba0d0a7276b00 (patch) | |
tree | 17f3eb310a24fabe871f4f407bd2b98f6ccb270c /lib/rdoc/ri | |
parent | e80e14c7882d3955eb88d078f43822af030a1bf4 (diff) | |
download | ruby-8e94bb29ae5c33d988cba29f130ba0d0a7276b00.tar.gz |
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
Diffstat (limited to 'lib/rdoc/ri')
-rw-r--r-- | lib/rdoc/ri/ri_cache.rb | 19 | ||||
-rw-r--r-- | lib/rdoc/ri/ri_descriptions.rb | 4 | ||||
-rw-r--r-- | lib/rdoc/ri/ri_driver.rb | 26 | ||||
-rw-r--r-- | lib/rdoc/ri/ri_options.rb | 8 | ||||
-rw-r--r-- | lib/rdoc/ri/ri_reader.rb | 13 |
5 files changed, 53 insertions, 17 deletions
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 |