find_attr_comment(var_name, attr_name, read = nil, write = nil)
public
Finds a comment for rb_define_attr, rb_attr or Document-attr.
var_name is the C class variable the attribute is defined on.
attr_name is the attribute’s name.
read and write are the read/write flags (‘1’ or
‘0’). Either both or neither must be provided.
# File lib/rdoc/parser/c.rb, line 392
def find_attr_comment var_name, attr_name, read = nil, write = nil
attr_name = Regexp.escape attr_name
rw = if read and write then
/\s*#{read}\s*,\s*#{write}\s*/m
else
/.*?/
end
if @content =~ %((?>/\*.*?\*/\s+))
rb_define_attr\((?:\s*#{var_name},)?\s*
"#{attr_name}"\s*,
#{rw}\)\s*;%m then
$1
elsif @content =~ %((?>/\*.*?\*/\s+))
rb_attr\(\s*#{var_name}\s*,
\s*#{attr_name}\s*,
#{rw},.*?\)\s*;%m then
$1
elsif @content =~ %Document-attr:\s#{attr_name}\s*?\n
((?>.*?\*/))%m then
$1
else
''
end
end