summaryrefslogtreecommitdiff
path: root/lib/rdoc/ri
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-16 20:28:44 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-16 20:28:44 +0000
commitbc8c73c42a552fcc1d414c3475c64099f5a246d6 (patch)
treeebee43a2f527178f880b89405e30d630158975b7 /lib/rdoc/ri
parent6ef31af2d178fb4916150d317ceafe156fccdf65 (diff)
Put RDoc comments into array.c, and refine rdoc/ri to deal with stuff that arose
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri')
-rw-r--r--lib/rdoc/ri/ri_cache.rb31
-rw-r--r--lib/rdoc/ri/ri_descriptions.rb7
-rw-r--r--lib/rdoc/ri/ri_formatter.rb2
-rw-r--r--lib/rdoc/ri/ri_reader.rb2
-rw-r--r--lib/rdoc/ri/ri_util.rb10
-rw-r--r--lib/rdoc/ri/ri_writer.rb2
6 files changed, 36 insertions, 18 deletions
diff --git a/lib/rdoc/ri/ri_cache.rb b/lib/rdoc/ri/ri_cache.rb
index 4ca976c4b9..da2a7e47ff 100644
--- a/lib/rdoc/ri/ri_cache.rb
+++ b/lib/rdoc/ri/ri_cache.rb
@@ -56,16 +56,16 @@ module RI
# return the list of local methods matching name
# We're split into two because we need distinct behavior
# when called from the toplevel
- def methods_matching(name)
- local_methods_matching(name)
+ def methods_matching(name, is_class_method)
+ local_methods_matching(name, is_class_method)
end
# Find methods matching 'name' in ourselves and in
# any classes we contain
- def recursively_find_methods_matching(name)
- res = local_methods_matching(name)
+ def recursively_find_methods_matching(name, is_class_method)
+ res = local_methods_matching(name, is_class_method)
@inferior_classes.each do |c|
- res.concat(c.recursively_find_methods_matching(name))
+ res.concat(c.recursively_find_methods_matching(name, is_class_method))
end
res
end
@@ -80,10 +80,19 @@ module RI
private
- # Return a list of all our methods matching a given string
- def local_methods_matching(name)
- @class_methods.find_all {|m| m.name[name] } +
- @instance_methods.find_all {|m| m.name[name] }
+ # Return a list of all our methods matching a given string.
+ # Is +is_class_methods+ if 'nil', we don't care if the method
+ # is a class method or not, otherwise we only return
+ # those methods that match
+ def local_methods_matching(name, is_class_method)
+ list = case is_class_method
+ when nil then @class_methods + @instance
+ when true then @class_methods
+ when false then @instance_methods
+ else fail "Unknown is_class_method"
+ end
+
+ list.find_all {|m| m.name[name]}
end
end
@@ -91,8 +100,8 @@ module RI
# for methods searches all classes, not just itself
class TopLevelEntry < ClassEntry
- def methods_matching(name)
- res = recursively_find_methods_matching(name)
+ def methods_matching(name, is_class_method)
+ res = recursively_find_methods_matching(name, is_class_method)
end
def full_name
diff --git a/lib/rdoc/ri/ri_descriptions.rb b/lib/rdoc/ri/ri_descriptions.rb
index e80b4ebe05..f99905719b 100644
--- a/lib/rdoc/ri/ri_descriptions.rb
+++ b/lib/rdoc/ri/ri_descriptions.rb
@@ -1,5 +1,9 @@
require 'yaml'
+# Descriptions are created by RDoc (in ri_generator) and
+# written out in serialized form into the documentation
+# tree. ri then reads these to generate the documentation
+
module RI
Alias = Struct.new(:old_name, :new_name)
AliasName = Struct.new(:name)
@@ -35,7 +39,8 @@ module RI
class ClassDescription < Description
- attr_accessor :method_list
+ attr_accessor :class_methods
+ attr_accessor :instance_methods
attr_accessor :attributes
attr_accessor :constants
attr_accessor :superclass
diff --git a/lib/rdoc/ri/ri_formatter.rb b/lib/rdoc/ri/ri_formatter.rb
index 052ac87906..1e70529bfe 100644
--- a/lib/rdoc/ri/ri_formatter.rb
+++ b/lib/rdoc/ri/ri_formatter.rb
@@ -55,7 +55,7 @@ module RI
txt.
gsub(%r{<tt>(.*?)</tt>}) { "+#$1+" } .
gsub(%r{<b>(.*?)</b>}) { "*#$1*" } .
- gsub(%r{<i>(.*?)</i>}) { "_#$1_" } .
+ gsub(%r{<em>(.*?)</em>}) { "_#$1_" } .
gsub(/&gt;/, '>').
gsub(/&lt;/, '<').
gsub(/&quot;/, '"').
diff --git a/lib/rdoc/ri/ri_reader.rb b/lib/rdoc/ri/ri_reader.rb
index f7e9e3074c..eb56d654fb 100644
--- a/lib/rdoc/ri/ri_reader.rb
+++ b/lib/rdoc/ri/ri_reader.rb
@@ -24,7 +24,7 @@ module RI
def find_methods(name, is_class_method, namespaces)
result = []
namespaces.each do |ns|
- result.concat ns.methods_matching(name)
+ result.concat ns.methods_matching(name, is_class_method)
end
result
end
diff --git a/lib/rdoc/ri/ri_util.rb b/lib/rdoc/ri/ri_util.rb
index 07f79b1d62..5d14650fac 100644
--- a/lib/rdoc/ri/ri_util.rb
+++ b/lib/rdoc/ri/ri_util.rb
@@ -9,6 +9,8 @@ class NameDescriptor
attr_reader :class_names
attr_reader :method_name
+
+ # true and false have the obvious meaning. nil means we don't care
attr_reader :is_class_method
# arg may be
@@ -25,9 +27,9 @@ class NameDescriptor
def initialize(arg)
@class_names = []
- separator = "."
+ separator = nil
- tokens = arg.split(/\b/)
+ tokens = arg.split(/(\.|::|#)/)
# Skip leading '::', '#' or '.', but remember it might
# be a method name qualifier
@@ -57,7 +59,9 @@ class NameDescriptor
if @method_name =~ /::|\.|#/ or !tokens.empty?
raise RiError.new("Bad argument: #{arg}")
end
- @is_class_method = separator == "::"
+ if separator
+ @is_class_method = separator == "::"
+ end
end
end
end
diff --git a/lib/rdoc/ri/ri_writer.rb b/lib/rdoc/ri/ri_writer.rb
index 072b3acfea..70468cb1f5 100644
--- a/lib/rdoc/ri/ri_writer.rb
+++ b/lib/rdoc/ri/ri_writer.rb
@@ -28,7 +28,7 @@ module RI
def add_method(class_desc, method_desc)
dir = path_to_dir(class_desc.full_name)
meth_file_name = File.join(dir, method_desc.name)
- if method_desc.is_class_method
+ if method_desc.is_singleton
meth_file_name += "-c.yaml"
else
meth_file_name += "-i.yaml"