diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rdoc/ri/display.rb | 8 | ||||
-rw-r--r-- | lib/rdoc/ri/driver.rb | 28 |
2 files changed, 26 insertions, 10 deletions
diff --git a/lib/rdoc/ri/display.rb b/lib/rdoc/ri/display.rb index d5ac8c2f01..3b24ef04ba 100644 --- a/lib/rdoc/ri/display.rb +++ b/lib/rdoc/ri/display.rb @@ -136,16 +136,16 @@ class RDoc::RI::DefaultDisplay def display_method_list(methods) page do - puts "More than one method matched your request. You can refine" - puts "your search by asking for information on one of:\n\n" + @formatter.raw_print_line("More than one method matched your request. You can refine") + @formatter.raw_print_line("your search by asking for information on one of:\n\n") @formatter.wrap(methods.map {|m| m.full_name} .join(", ")) end end def display_class_list(namespaces) page do - puts "More than one class or module matched your request. You can refine" - puts "your search by asking for information on one of:\n\n" + @formatter.raw_print_line("More than one class or module matched your request. You can refine") + @formatter.raw_print_line("your search by asking for information on one of:\n\n") @formatter.wrap(namespaces.map {|m| m.full_name}.join(", ")) end end diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb index 9afdf7b7bc..67817b1806 100644 --- a/lib/rdoc/ri/driver.rb +++ b/lib/rdoc/ri/driver.rb @@ -346,7 +346,7 @@ Options may also be set in the 'RI' environment variable. def run if @names.empty? then - @display.list_known_classes select_classes + @display.list_known_classes class_cache.keys.sort else @names.each do |name| case name @@ -371,17 +371,33 @@ Options may also be set in the 'RI' environment variable. if class_cache.key? name then display_class name else - @display.list_known_classes select_classes(/^#{name}/) + methods = select_methods(/^#{name}/) + if methods.size == 0 + abort "Nothing known about #{name}" + elsif methods.size == 1 + @display.display_method_info methods.first + else + @display.display_method_list methods + end end end end end end - def select_classes(pattern = nil) - classes = class_cache.keys.sort - classes = classes.grep pattern if pattern - classes + def select_methods(pattern) + methods = [] + class_cache.keys.sort.each do |klass| + class_cache[klass]["instance_methods"].map{|h|h["name"]}.grep(pattern) do |name| + method = load_cache_for(klass)[klass+'#'+name] + methods << method if method + end + class_cache[klass]["class_methods"].map{|h|h["name"]}.grep(pattern) do |name| + method = load_cache_for(klass)[klass+'::'+name] + methods << method if method + end + end + methods end def write_cache(cache, path) |