summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-27 16:39:44 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-27 16:39:44 +0000
commit68d292236d0ad8687341669b272fb2536f120a95 (patch)
treed4c355f81c3a050f7768f03405988db1738caf0f /lib
parent75cc3e4f754b7b1ddcec69407b1641f396acf919 (diff)
Add "Document-method:" capability
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rdoc/parsers/parse_c.rb36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb
index 26b3ae4b56..d28ec941e8 100644
--- a/lib/rdoc/parsers/parse_c.rb
+++ b/lib/rdoc/parsers/parse_c.rb
@@ -181,7 +181,9 @@ module RDoc
@known_classes[var_name] = cm.full_name
end
-
+
+ ############################################################
+
def find_class_comment(class_name, class_meth)
comment = nil
if @body =~ %r{((?>/\*.*?\*/\s+))
@@ -193,6 +195,8 @@ module RDoc
class_meth.comment = mangle_comment(comment) if comment
end
+ ############################################################
+
def do_classes
@body.scan(/(\w+)\s* = \s*rb_define_module\(\s*"(\w+)"\s*\)/mx) do
|var_name, class_name|
@@ -238,6 +242,7 @@ module RDoc
end
+ ############################################################
def do_methods
@body.scan(/rb_define_(singleton_method|method|module_function)\(\s*(\w+),
@@ -271,6 +276,7 @@ module RDoc
end
end
+ ############################################################
def handle_method(type, var_name, meth_name, meth_body, param_count)
class_name = @known_classes[var_name] || var_name
@@ -301,6 +307,8 @@ module RDoc
end
end
+ ############################################################
+
# Find the C code corresponding to a c method
def find_body(meth_name, meth_obj)
if @body =~ %r{((?>/\*.*?\*/\s+))(static\s+)?VALUE\s+#{meth_name}
@@ -315,6 +323,17 @@ module RDoc
body_text = $&
end
+ # The comment block may have been overridden with a
+ # 'Document-method' block. This happens in the interpreter
+ # when multiple methods are vectored through to the same
+ # C method but those methods are logically distinct (for
+ # example Kernel.hash and Kernel.object_id share the same
+ # implementation
+
+ override_comment = find_override_comment(meth_obj.name)
+ comment = override_comment if override_comment
+
+ #
# If the comment block contains a section that looks like
# call-seq:
# Array.new
@@ -337,6 +356,19 @@ module RDoc
end
end
+ ############################################################
+
+ def find_override_comment(meth_name)
+ comment = nil
+ puts "Override #{meth_name}"
+ if @body =~ %r{Document-method:\s#{meth_name}.*?\n((?>.*?\*/))}m
+ comment = $1
+ end
+ comment
+ end
+
+ ############################################################
+
# Look for includes of the form
# rb_include_module(rb_cArray, rb_mEnumerable);
def do_includes
@@ -348,6 +380,8 @@ module RDoc
end
end
+ ############################################################
+
# Remove the /*'s and leading asterisks from C comments
def mangle_comment(comment)