Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/parser/c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def handle_attr(var_name, attr_name, read, write)
comment = find_attr_comment var_name, attr_name
comment.normalize

name = attr_name.gsub(/rb_intern\("([^"]+)"\)/, '\1')
name = attr_name.gsub(/rb_intern(?:_const)?\("([^"]+)"\)/, '\1')

attr = RDoc::Attr.new '', name, rw, comment

Expand Down
44 changes: 44 additions & 0 deletions test/test_rdoc_parser_c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,50 @@ def test_do_attr_rb_attr
assert_equal 'This is a writer', writer.comment.text
end

def test_do_attr_rb_attr_2
content = <<-EOF
void Init_Blah(void) {
cBlah = rb_define_class("Blah", rb_cObject);

/*
* This is an accessor
*/
rb_attr(cBlah, rb_intern_const("accessor"), 1, 1, Qfalse);

/*
* This is a reader
*/
rb_attr(cBlah, rb_intern_const("reader"), 1, 0, Qfalse);

/*
* This is a writer
*/
rb_attr(cBlah, rb_intern_const("writer"), 0, 1, Qfalse);
}
EOF

klass = util_get_class content, 'cBlah'

attrs = klass.attributes
assert_equal 3, attrs.length, attrs.inspect

accessor = attrs.shift
assert_equal 'accessor', accessor.name
assert_equal 'RW', accessor.rw
assert_equal 'This is an accessor', accessor.comment.text
assert_equal @top_level, accessor.file

reader = attrs.shift
assert_equal 'reader', reader.name
assert_equal 'R', reader.rw
assert_equal 'This is a reader', reader.comment.text

writer = attrs.shift
assert_equal 'writer', writer.name
assert_equal 'W', writer.rw
assert_equal 'This is a writer', writer.comment.text
end

def test_do_attr_rb_define_attr
content = <<-EOF
void Init_Blah(void) {
Expand Down