diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-01-07 03:33:19 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-01-07 03:33:19 +0000 |
commit | 009596eeda00170c67fa820c2b78525cffe08a91 (patch) | |
tree | b0f45f8ab5c963a19eaea0bcd7f7a4776c74937f /lib/rdoc/parsers/parse_c.rb | |
parent | 666ffdcbcadc3865138388002e20a05bc956bd34 (diff) | |
download | ruby-009596eeda00170c67fa820c2b78525cffe08a91.tar.gz ruby-009596eeda00170c67fa820c2b78525cffe08a91.tar.xz ruby-009596eeda00170c67fa820c2b78525cffe08a91.zip |
Merge RDoc updates from matzruby 11502, 11503, 11504
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/parsers/parse_c.rb')
-rw-r--r-- | lib/rdoc/parsers/parse_c.rb | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb index 7053fac7d..ec9ae1877 100644 --- a/lib/rdoc/parsers/parse_c.rb +++ b/lib/rdoc/parsers/parse_c.rb @@ -266,7 +266,31 @@ module RDoc @known_classes[var_name] = cm.full_name end - ############################################################ + ## + # Look for class or module documentation above Init_+class_name+(void), + # in a Document-class +class_name+ (or module) comment or above an + # rb_define_class (or module). If a comment is supplied above a matching + # Init_ and a rb_define_class the Init_ comment is used. + # + # /* + # * This is a comment for Foo + # */ + # Init_Foo(void) { + # VALUE cFoo = rb_define_class("Foo", rb_cObject); + # } + # + # /* + # * Document-class: Foo + # * This is a comment for Foo + # */ + # Init_foo(void) { + # VALUE cFoo = rb_define_class("Foo", rb_cObject); + # } + # + # /* + # * This is a comment for Foo + # */ + # VALUE cFoo = rb_define_class("Foo", rb_cObject); def find_class_comment(class_name, class_meth) comment = nil @@ -275,6 +299,18 @@ module RDoc comment = $1 elsif @body =~ %r{Document-(class|module):\s#{class_name}\s*?\n((?>.*?\*/))}m comment = $2 + else + if @body =~ /rb_define_(class|module)/m then + class_name = class_name.split("::").last + comments = [] + @body.split(/(\/\*.*?\*\/)\s*?\n/m).each_with_index do |chunk, index| + comments[index] = chunk + if chunk =~ /rb_define_(class|module).*?"(#{class_name})"/m then + comment = comments[index-1] + break + end + end + end end class_meth.comment = mangle_comment(comment) if comment end |