summaryrefslogtreecommitdiff
path: root/lib/rdoc/ri
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/ri')
-rw-r--r--lib/rdoc/ri/ri_cache.rb16
-rw-r--r--lib/rdoc/ri/ri_descriptions.rb8
-rw-r--r--lib/rdoc/ri/ri_paths.rb12
-rw-r--r--lib/rdoc/ri/ri_reader.rb10
-rw-r--r--lib/rdoc/ri/ri_writer.rb16
5 files changed, 54 insertions, 8 deletions
diff --git a/lib/rdoc/ri/ri_cache.rb b/lib/rdoc/ri/ri_cache.rb
index f2cdbf6f38..0a2fac184c 100644
--- a/lib/rdoc/ri/ri_cache.rb
+++ b/lib/rdoc/ri/ri_cache.rb
@@ -31,7 +31,7 @@ module RI
if name =~ /^(.*?)-(c|i).yaml$/
external_name = $1
is_class_method = $2 == "c"
- internal_name = external_name
+ internal_name = RiWriter.external_to_internal(external_name)
list = is_class_method ? @class_methods : @instance_methods
path = File.join(dir, name)
list << MethodEntry.new(path, internal_name, is_class_method, self)
@@ -53,6 +53,11 @@ module RI
@inferior_classes.find_all {|c| c.name[name]}
end
+ # Return an exact match to a particular name
+ def contained_class_named(name)
+ @inferior_classes.find {|c| c.name == name}
+ end
+
# return the list of local methods matching name
# We're split into two because we need distinct behavior
# when called from the toplevel
@@ -72,7 +77,7 @@ module RI
# Return our full name
- def full_name
+ def full_namep
res = @in_class.full_name
res << "::" unless res.empty?
res << @name
@@ -93,7 +98,7 @@ module RI
else fail "Unknown is_class_method"
end
- list.find_all {|m| m.name[name]}
+ list.find_all {|m| m.name; m.name[name]}
end
end
@@ -108,6 +113,11 @@ module RI
def full_name
""
end
+
+ def module_named(name)
+
+ end
+
end
class MethodEntry
diff --git a/lib/rdoc/ri/ri_descriptions.rb b/lib/rdoc/ri/ri_descriptions.rb
index f99905719b..47984cf41d 100644
--- a/lib/rdoc/ri/ri_descriptions.rb
+++ b/lib/rdoc/ri/ri_descriptions.rb
@@ -46,6 +46,14 @@ module RI
attr_accessor :superclass
attr_accessor :includes
+ # merge in another class desscription into this one
+ def merge_in(old)
+ @class_methods.concat(old.class_methods).sort!
+ @instance_methods.concat(old.instance_methods).sort!
+ @attributes.concat(old.attributes).sort!
+ @constants.concat(old.constants).sort!
+ @includes.concat(old.includes).sort!
+ end
end
class MethodDescription < Description
diff --git a/lib/rdoc/ri/ri_paths.rb b/lib/rdoc/ri/ri_paths.rb
index 14288d9a94..ff8257a546 100644
--- a/lib/rdoc/ri/ri_paths.rb
+++ b/lib/rdoc/ri/ri_paths.rb
@@ -15,8 +15,8 @@ module RI
#
# There's contention about all this, but for now:
#
- # system:: $prefix/lib/ruby/<version>/doc/rdoc
- # site:: $prefix/lib/ruby/site_dir/<version>/doc/rdoc
+ # system:: $datadir/ri/<ver>/system/...
+ # site:: $datadir/ri/<ver>/site/...
# user:: ~/.rdoc
module Paths
@@ -26,8 +26,11 @@ module RI
DOC_DIR = "doc/rdoc"
- SYSDIR = File.join(Config::CONFIG['rubylibdir'], DOC_DIR)
- SITEDIR = File.join(Config::CONFIG['sitelibdir'], DOC_DIR)
+ version = Config::CONFIG['ruby_version']
+
+ base = File.join(Config::CONFIG['datadir'], "ri", version)
+ SYSDIR = File.join(base, "system")
+ SITEDIR = File.join(base, "site")
homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH']
if homedir
@@ -36,6 +39,7 @@ module RI
HOMEDIR = nil
end
+ # This is the search path for 'ri'
PATH = [ SYSDIR, SITEDIR, HOMEDIR ].find_all {|p| p && File.directory?(p)}
end
end
diff --git a/lib/rdoc/ri/ri_reader.rb b/lib/rdoc/ri/ri_reader.rb
index eb56d654fb..dd647b3f89 100644
--- a/lib/rdoc/ri/ri_reader.rb
+++ b/lib/rdoc/ri/ri_reader.rb
@@ -21,6 +21,16 @@ module RI
result
end
+ def find_class_by_name(full_name)
+ names = full_name.split(/::/)
+ ns = @cache.toplevel
+ for name in names
+ ns = ns.contained_class_named(name)
+ return nil if ns.nil?
+ end
+ get_class(ns)
+ end
+
def find_methods(name, is_class_method, namespaces)
result = []
namespaces.each do |ns|
diff --git a/lib/rdoc/ri/ri_writer.rb b/lib/rdoc/ri/ri_writer.rb
index 70468cb1f5..78c68e8409 100644
--- a/lib/rdoc/ri/ri_writer.rb
+++ b/lib/rdoc/ri/ri_writer.rb
@@ -8,6 +8,19 @@ module RI
end
+ # Convert a name from internal form (containing punctuation)
+ # to an external form (where punctuation is replaced
+ # by %xx)
+
+ def RiWriter.internal_to_external(name)
+ name.gsub(/\W/) { sprintf("%%%02x", $&[0]) }
+ end
+
+ # And the reverse operation
+ def RiWriter.external_to_internal(name)
+ name.gsub(/%([0-9a-f]{2,2})/) { $1.to_i(16).chr }
+ end
+
def initialize(base_dir)
@base_dir = base_dir
end
@@ -27,7 +40,8 @@ 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)
+ file_name = RiWriter.internal_to_external(method_desc.name)
+ meth_file_name = File.join(dir, file_name)
if method_desc.is_singleton
meth_file_name += "-c.yaml"
else