method
handle_method
v2_1_10 -
Show latest stable
- Class:
RDoc::Parser::C
handle_method(type, var_name, meth_name, function, param_count, source_file = nil)public
Adds an RDoc::AnyMethod meth_name defined on a class or module assigned to var_name. type is the type of method definition function used. singleton_method and module_function create a singleton method.
# File lib/rdoc/parser/c.rb, line 980
def handle_method(type, var_name, meth_name, function, param_count,
source_file = nil)
class_name = @known_classes[var_name]
singleton = @singleton_classes.key? var_name
@methods[var_name][function] << meth_name
return unless class_name
class_obj = find_class var_name, class_name
if class_obj then
if meth_name == 'initialize' then
meth_name = 'new'
singleton = true
type = 'method' # force public
end
meth_obj = RDoc::AnyMethod.new '', meth_name
meth_obj.c_function = function
meth_obj.singleton =
singleton || ]singleton_method module_function].include?(type)
p_count = Integer(param_count) rescue -1
if source_file then
file_name = File.join @file_dir, source_file
if File.exist? file_name then
file_content = File.read file_name
else
@options.warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
end
else
file_content = @content
end
body = find_body class_name, function, meth_obj, file_content
if body and meth_obj.document_self then
meth_obj.params = if p_count < -1 then # -2 is Array
'(*args)'
elsif p_count == -1 then # argc, argv
rb_scan_args body
else
"(#{(1..p_count).map { |i| "p#{i}" }.join ', '})"
end
meth_obj.record_location @top_level
class_obj.add_method meth_obj
@stats.add_method meth_obj
meth_obj.visibility = :private if 'private_method' == type
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