ruby-changes:72340
From: Nobuyoshi <ko1@a...>
Date: Tue, 28 Jun 2022 14:52:04 +0900 (JST)
Subject: [ruby-changes:72340] 51be2cf6d2 (master): [ruby/rdoc] Parse also InitVM-prefixed functions
https://git.ruby-lang.org/ruby.git/commit/?id=51be2cf6d2 From 51be2cf6d23466e173ad66eac9a4b3ae32097cc4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 28 Jun 2022 14:29:12 +0900 Subject: [ruby/rdoc] Parse also InitVM-prefixed functions Initialization depending on VM is separated. https://github.com/ruby/rdoc/commit/030d10fccd --- lib/rdoc/parser/c.rb | 2 +- test/rdoc/test_rdoc_parser_c.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb index 52317c5ad8..83a216a8ac 100644 --- a/lib/rdoc/parser/c.rb +++ b/lib/rdoc/parser/c.rb @@ -720,7 +720,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L720 ((?>/\*.*?\*/\s+)) (static\s+)? void\s+ - Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xmi then + Init(?:VM)?_(?i:#{class_name})\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xm then comment = $1.sub(%r%Document-(?:class|module):\s+#{class_name}%, '') elsif @content =~ %r%Document-(?:class|module):\s+#{class_name}\s*? (?:<\s+[:,\w]+)?\n((?>.*?\*/))%xm then diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb index c7312bebba..b7e1648cd6 100644 --- a/test/rdoc/test_rdoc_parser_c.rb +++ b/test/rdoc/test_rdoc_parser_c.rb @@ -857,6 +857,23 @@ Init_Foo(void) { https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_parser_c.rb#L857 assert_equal "a comment for class Foo", klass.comment.text end + + def test_find_class_comment_initvm + content = <<-EOF +/* + * a comment for class Foo + */ +void +InitVM_Foo(void) { + VALUE foo = rb_define_class("Foo", rb_cObject); +} + EOF + + klass = util_get_class content, 'foo' + + assert_equal "a comment for class Foo", klass.comment.text + end + def test_find_class_comment_define_class content = <<-EOF /* -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/