Parses a meta-programmed attribute and creates an RDoc::Attr.
To create foo and bar attributes on class C with comment “My
attributes”:
class C### :attr:## My attributesmy_attr:foo,:barend
To create a foo attribute on class C with comment “My attribute”:
class C### :attr: foo## My attributemy_attr:foo,:barend
# File lib/rdoc/parser/ruby.rb, line 861
def parse_meta_attr(context, single, tk, comment)
args = parse_symbol_arg
rw = "?"
# If nodoc is given, don't document any of them
tmp = RDoc::CodeObject.new
read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS
if comment.sub!(/^# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/, '') then
rw = case $1
when 'attr_reader' then 'R'
when 'attr_writer' then 'W'
else 'RW'
end
name = $3 unless $3.empty?
end
if name then
att = RDoc::Attr.new get_tkread, name, rw, comment, single == SINGLE
att.record_location @top_level
context.add_attribute att
@stats.add_attribute att
else
args.each do |attr_name|
att = RDoc::Attr.new(get_tkread, attr_name, rw, comment,
single == SINGLE)
att.record_location @top_level
context.add_attribute att
@stats.add_attribute att
end
end
end