diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-07-15 15:00:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-07-15 15:00:11 +0000 |
commit | 2bfa23f0347d172367f77d78265475c3fb73ed31 (patch) | |
tree | c85596fa30897779d708fe6d4e815928262df6bd /lib/rdoc/parsers | |
parent | fd0f36a4a8e6877ba160f405a9d10f36ee662a4a (diff) | |
download | ruby-2bfa23f0347d172367f77d78265475c3fb73ed31.tar.gz |
* lib/rdoc/parsers/parse_c.rb (handle_class_module): handle a
module enclosed in a built-in module. fixed: [ruby-talk:148239]
* lib/rdoc/parsers/parse_c.rb (find_body): allow macros as methods.
* lib/rdoc/parsers/parse_c.rb (find_call_seq): allow :nodoc: modifier
in C. [ruby-core:04572]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/parsers')
-rw-r--r-- | lib/rdoc/parsers/parse_c.rb | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb index 37c2069311..e6c18cb0ff 100644 --- a/lib/rdoc/parsers/parse_c.rb +++ b/lib/rdoc/parsers/parse_c.rb @@ -227,6 +227,13 @@ module RDoc if in_module enclosure = @classes[in_module] unless enclosure + if enclosure = @known_classes[in_module] + handle_class_module(in_module, (/^rb_m/ =~ in_module ? "module" : "class"), + enclosure, nil, nil) + enclosure = @classes[in_module] + end + end + unless enclosure warn("Enclosing class/module '#{in_module}' for " + "#{class_mod} #{class_name} not known") return @@ -234,7 +241,7 @@ module RDoc else enclosure = @top_level end - + if class_mod == "class" cm = enclosure.add_class(NormalClass, class_name, parent_name) @stats.num_classes += 1 @@ -524,24 +531,25 @@ module RDoc end if source_file - file_name = File.join(@file_dir, source_file) + file_name = File.join(@file_dir, source_file) body = (@@known_bodies[source_file] ||= File.read(file_name)) else body = @body end - find_body(meth_body, meth_obj, body) - class_obj.add_method(meth_obj) + if find_body(meth_body, meth_obj, body) and meth_obj.document_self + class_obj.add_method(meth_obj) + end end end ############################################################ # Find the C code corresponding to a Ruby method - def find_body(meth_name, meth_obj, body) - if body =~ %r{((?>/\*.*?\*/\s*))(static\s+)?VALUE\s+#{meth_name} - \s*(\(.*?\)).*?^}xm - - comment, params = $1, $3 + def find_body(meth_name, meth_obj, body, quiet = false) + case body + when %r{((?>/\*.*?\*/\s*))(?:static\s+)?VALUE\s+#{meth_name} + \s*(\(.*?\)).*?^}xm + comment, params = $1, $2 body_text = $& # see if we can find the whole body @@ -561,25 +569,36 @@ module RDoc override_comment = find_override_comment(meth_obj.name) comment = override_comment if override_comment - find_call_seq(comment, meth_obj) if comment + find_modifiers(comment, meth_obj) if comment # meth_obj.params = params meth_obj.start_collecting_tokens meth_obj.add_token(RubyToken::Token.new(1,1).set_text(body_text)) meth_obj.comment = mangle_comment(comment) - + when %r{((?>/\*.*?\*/\s*))^\s*\#\s*define\s+#{meth_name}\s+(\w+)}m + comment = $1 + find_body($2, meth_obj, body, true) + find_modifiers(comment, meth_obj) + meth_obj.comment = mangle_comment(comment) + meth_obj.comment + when %r{^\s*\#\s*define\s+#{meth_name}\s+(\w+)}m + unless find_body($1, meth_obj, body, true) + warn "No definition for #{meth_name}" unless quiet + return false + end else # No body, but might still have an override comment comment = find_override_comment(meth_obj.name) if comment - find_call_seq(comment, meth_obj) + find_modifiers(comment, meth_obj) meth_obj.comment = mangle_comment(comment) else - warn "No definition for #{meth_name}" + warn "No definition for #{meth_name}" unless quiet + return false end end + true end @@ -590,8 +609,13 @@ module RDoc # Array.new # Array.new(10) # use it for the parameters - def find_call_seq(comment, meth_obj) - if comment.sub!(/call-seq:(.*?)^\s*\*?\s*$/m, '') + def find_modifiers(comment, meth_obj) + if comment.sub!(/:nodoc:\s*^\s*\*?\s*$/m, '') or + comment.sub!(/\A\/\*\s*:nodoc:\s*\*\/\Z/, '') + meth_obj.document_self = false + end + if comment.sub!(/call-seq:(.*?)^\s*\*?\s*$/m, '') or + comment.sub!(/\A\/\*\s*call-seq:(.*?)\*\/\Z/, '') seq = $1 seq.gsub!(/^\s*\*\s*/, '') meth_obj.call_seq = seq |