method
find_body
v1_9_2_180 -
Show latest stable
- Class:
RDoc::Parser::C
find_body(class_name, meth_name, meth_obj, body, quiet = false)public
# File lib/rdoc/parser/c.rb, line 281
def find_body(class_name, meth_name, meth_obj, body, quiet = false)
case body
when %((?>/\*.*?\*/\s*))((?:(?:static|SWIGINTERN)\s+)?(?:intern\s+)?VALUE\s+#{meth_name}
\s*(\([^)]*\))([^;]|$))"m
comment = $1
body_text = $2
params = $3
remove_private_comments comment if comment
# see if we can find the whole body
re = Regexp.escape(body_text) + '[^(]*^\{.*?^\}'
body_text = $& if /#{re}/ =~ body
# 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 class_name, meth_obj.name
comment = override_comment if override_comment
find_modifiers comment, meth_obj if comment
#meth_obj.params = params
meth_obj.start_collecting_tokens
tk = RDoc::RubyToken::Token.new nil, 1, 1
tk.set_text body_text
meth_obj.add_token tk
meth_obj.comment = strip_stars comment
when %{((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+#{meth_name}\s+(\w+))}
comment = $1
body_text = $2
find_body class_name, $3, meth_obj, body, true
find_modifiers comment, meth_obj
meth_obj.start_collecting_tokens
tk = RDoc::RubyToken::Token.new nil, 1, 1
tk.set_text body_text
meth_obj.add_token tk
meth_obj.comment = strip_stars(comment) + meth_obj.comment.to_s
when %{^\s*\#\s*define\s+#{meth_name}\s+(\w+)}
unless find_body(class_name, $1, meth_obj, body, true)
warn "No definition for #{meth_name}" unless @options.quiet
return false
end
else
# No body, but might still have an override comment
comment = find_override_comment(class_name, meth_obj.name)
if comment
find_modifiers(comment, meth_obj)
meth_obj.comment = strip_stars comment
else
warn "No definition for #{meth_name}" unless @options.quiet
return false
end
end
true
end Related methods
- Instance methods
- do_aliases
- do_classes
- do_constants
- do_includes
- do_methods
- find_attr_comment
- find_body
- find_class
- find_class_comment
- find_const_comment
- find_modifiers
- find_override_comment
- handle_attr
- handle_class_module
- handle_constants
- handle_ifdefs_in
- handle_method
- handle_tab_width
- look_for_directives_in
- remove_commented_out_lines
- remove_private_comments
- scan
- Class methods
- new
- reset