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
10 changes: 9 additions & 1 deletion lib/rdoc/parser/c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,20 @@ def do_classes_and_modules
next
end

var_name = $~[:var_name]
type = $~[:module] ? :module : :class
class_name = $~[:class_name]
parent_name = $~[:parent_name] || $~[:path]
under = $~[:under]
attributes = $~[:attributes]

handle_class_module($~[:var_name], type, class_name, parent_name, under)
handle_class_module(var_name, type, class_name, parent_name, under)
if attributes and !parent_name # rb_struct_define *not* without_accessor
true_flag = 'Qtrue'
attributes.scan(/"\K\w+(?=")/) do |attr_name|
handle_attr var_name, attr_name, true_flag, true_flag
end
end
end
end

Expand Down
14 changes: 14 additions & 0 deletions test/rdoc/test_rdoc_parser_c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ def test_do_classes_struct

klass = util_get_class content, 'cFoo'
assert_equal "this is the Foo class", klass.comment.text

attributes = klass.attributes
assert_equal 3, attributes.size, -> {attributes}
["some", "various", "fields"].zip(attributes) do |name, attr|
assert_equal RDoc::Attr.new("", name, "RW", ""), attr
end
end

def test_do_classes_struct_under
Expand All @@ -326,6 +332,12 @@ def test_do_classes_struct_under
klass = util_get_class content, 'cFoo'
assert_equal 'Kernel::Foo', klass.full_name
assert_equal "this is the Foo class under Kernel", klass.comment.text

attributes = klass.attributes
assert_equal 3, attributes.size, -> {attributes}
["some", "various", "fields"].zip(attributes) do |name, attr|
assert_equal RDoc::Attr.new("", name, "RW", ""), attr
end
end

def test_do_classes_struct_without_accessor
Expand All @@ -340,6 +352,7 @@ def test_do_classes_struct_without_accessor

klass = util_get_class content, 'cFoo'
assert_equal "this is the Foo class", klass.comment.text
assert_empty klass.attributes
end

def test_do_classes_struct_without_accessor_under
Expand All @@ -355,6 +368,7 @@ def test_do_classes_struct_without_accessor_under
klass = util_get_class content, 'cFoo'
assert_equal 'Kernel::Foo', klass.full_name
assert_equal "this is the Foo class under Kernel", klass.comment.text
assert_empty klass.attributes
end

def test_do_classes_class_under
Expand Down