method
parse_comment
v1_9_2_180 -
Show latest stable
- Class:
RDoc::Parser::Ruby
parse_comment(container, tk, comment)public
Generates an RDoc::Method or RDoc::Attr from comment by looking for :method: or :attr: directives in comment.
# File lib/rdoc/parser/ruby.rb, line 670
def parse_comment(container, tk, comment)
line_no = tk.line_no
column = tk.char_no
singleton = !!comment.sub!(/(^# +:?)(singleton-)(method:)/, '\1\3')
# REFACTOR
if comment.sub!(/^# +:?method: *(\S*).*?\n/, '') then
name = $1 unless $1.empty?
meth = RDoc::GhostMethod.new get_tkread, name
meth.singleton = singleton
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 if meth.document_self
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
container.add_attribute att
@stats.add_method att
end
end Related methods
- Instance methods
- collect_first_comment
- error
- extract_call_seq
- get_bool
- get_class_or_module
- get_class_specification
- get_constant
- get_constant_with_optional_parens
- get_symbol_or_name
- look_for_directives_in
- make_message
- parse_alias
- parse_attr
- parse_attr_accessor
- parse_call_parameters
- parse_class
- parse_comment
- parse_constant
- parse_include
- parse_meta_attr
- parse_meta_method
- parse_method
- parse_method_or_yield_parameters
- parse_method_parameters
- parse_module
- parse_require
- parse_statements
- parse_symbol_arg
- parse_symbol_in_arg
- parse_top_level_statements
- parse_visibility
- parse_yield
- read_directive
- read_documentation_modifiers
- remove_private_comments
- scan
- skip_for_variable
- skip_method
- skip_optional_do_after_expression
- skip_tkspace_comment
- warn
- Class methods
- new