parse_comment(container, tk, comment)
public
Generates an RDoc::Method or RDoc::Attr from
comment by looking for :method: or :attr: directives in
comment.
Show source
def parse_comment(container, tk, comment)
column = tk.char_no
offset = tk.seek
line_no = tk.line_no
singleton = !!comment.sub!(/(^# +:?)(singleton-)(method:)/, '\1\3')
if comment.sub!(/^# +:?method: *(\S*).*?\n/, '') then
name = $1 unless $1.empty?
meth = RDoc::GhostMethod.new get_tkread, name
meth.record_location @top_level
meth.singleton = singleton
meth.offset = offset
meth.line = line_no
meth.start_collecting_tokens
indent = TkSPACE.new nil, 1, 1
indent.set_text " " * column
position_comment = TkCOMMENT.new nil, line_no, 1
position_comment.set_text "# File #{@top_level.absolute_name}, line #{line_no}"
meth.add_tokens [position_comment, NEWLINE_TOKEN, indent]
meth.params = ''
extract_call_seq comment, meth
return unless meth.name
container.add_method meth
meth.comment = comment
@stats.add_method meth
elsif 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?
att = RDoc::Attr.new get_tkread, name, rw, comment
att.record_location @top_level
att.offset = offset
att.line = line_no
container.add_attribute att
@stats.add_attribute att
end
true
end