Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v2_2_9) is shown here.
find_body(class_name, meth_name, meth_obj, file_content, quiet = false)public
# File lib/rdoc/parser/c.rb, line 611
def find_body class_name, meth_name, meth_obj, file_content, quiet = false
case file_content
when %((?>/\*.*?\*/\s*)?)
((?:(?:\w+)\s+)?
(?:intern\s+)?VALUE\s+#{meth_name}
\s*(\([^)]*\))([^;]|$))%m then
comment = RDoc::Comment.new $1, @top_level
body = $2
offset, = $~.offset(2)
comment.remove_private if comment
# try to find the whole body
body = $& if /#{Regexp.escape body}[^(]*?\{.*?^\}/ =~ file_content
# 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
comment = override_comment if override_comment
comment.normalize
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
meth_obj.add_token tk
meth_obj.comment = comment
meth_obj.offset = offset
meth_obj.line = file_content[0, offset].count("\n") + 1
body
when %((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+#{meth_name}\s+(\w+))% then
comment = RDoc::Comment.new $1, @top_level
body = $2
offset = $~.offset(2).first
find_body class_name, $3, meth_obj, file_content, true
comment.normalize
find_modifiers comment, meth_obj
meth_obj.start_collecting_tokens
tk = RDoc::RubyToken::Token.new nil, 1, 1
tk.set_text body
meth_obj.add_token tk
meth_obj.comment = comment
meth_obj.offset = offset
meth_obj.line = file_content[0, offset].count("\n") + 1
body
when %^\s*\#\s*define\s+#{meth_name}\s+(\w+)% then
# with no comment we hope the aliased definition has it and use it's
# definition
body = find_body(class_name, $1, meth_obj, file_content, true)
return body if body
@options.warn "No definition for #{meth_name}"
false
else # No body, but might still have an override comment
comment = find_override_comment class_name, meth_obj
if comment then
comment.normalize
find_modifiers comment, meth_obj
meth_obj.comment = comment
''
else
@options.warn "No definition for #{meth_name}"
false
end
end
end Related methods
- Instance methods
- deduplicate_call_seq
- deduplicate_method_name
- do_aliases
- do_attrs
- do_boot_defclass
- do_classes
- do_constants
- do_define_class
- do_define_class_under
- do_define_module
- do_define_module_under
- do_includes
- do_methods
- do_missing
- do_modules
- do_singleton_class
- do_struct_define_without_accessor
- find_alias_comment
- 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_singleton
- handle_tab_width
- load_variable_map
- look_for_directives_in
- rb_scan_args
- remove_commented_out_lines
- scan
- Class methods
- new