method
parse_statements
v1_8_7_72 -
Show latest stable
- Class:
RDoc::RubyParser
parse_statements(container, single=NORMAL, current_method=nil, comment='')private
No documentation available.
# File lib/rdoc/parsers/parse_rb.rb, line 1577
def parse_statements(container, single=NORMAL, current_method=nil, comment='')
nest = 1
save_visibility = container.visibility
# if container.kind_of?(TopLevel)
# else
# comment = ''
# end
non_comment_seen = true
while tk = get_tk
keep_comment = false
non_comment_seen = true unless tk.kind_of?(TkCOMMENT)
case tk
when TkNL
skip_tkspace(true) # Skip blanks and newlines
tk = get_tk
if tk.kind_of?(TkCOMMENT)
if non_comment_seen
comment = ''
non_comment_seen = false
end
while tk.kind_of?(TkCOMMENT)
comment << tk.text << "\n"
tk = get_tk # this is the newline
skip_tkspace(false) # leading spaces
tk = get_tk
end
unless comment.empty?
look_for_directives_in(container, comment)
if container.done_documenting
container.ongoing_visibility = save_visibility
# return
end
end
keep_comment = true
else
non_comment_seen = true
end
unget_tk(tk)
keep_comment = true
when TkCLASS
if container.document_children
parse_class(container, single, tk, comment)
else
nest += 1
end
when TkMODULE
if container.document_children
parse_module(container, single, tk, comment)
else
nest += 1
end
when TkDEF
if container.document_self
parse_method(container, single, tk, comment)
else
nest += 1
end
when TkCONSTANT
if container.document_self
parse_constant(container, single, tk, comment)
end
when TkALIAS
if container.document_self
parse_alias(container, single, tk, comment)
end
when TkYIELD
if current_method.nil?
warn("Warning: yield outside of method") if container.document_self
else
parse_yield(container, single, tk, current_method)
end
# Until and While can have a 'do', which shouldn't increas
# the nesting. We can't solve the general case, but we can
# handle most occurrences by ignoring a do at the end of a line
when TkUNTIL, TkWHILE
nest += 1
puts "FOUND #{tk.class} in #{container.name}, nest = #{nest}, " +
"line #{tk.line_no}" if $DEBUG
skip_optional_do_after_expression
# 'for' is trickier
when TkFOR
nest += 1
puts "FOUND #{tk.class} in #{container.name}, nest = #{nest}, " +
"line #{tk.line_no}" if $DEBUG
skip_for_variable
skip_optional_do_after_expression
when TkCASE, TkDO, TkIF, TkUNLESS, TkBEGIN
nest += 1
puts "Found #{tk.class} in #{container.name}, nest = #{nest}, " +
"line #{tk.line_no}" if $DEBUG
when TkIDENTIFIER
if nest == 1 and current_method.nil?
case tk.name
when "private", "protected", "public",
"private_class_method", "public_class_method"
parse_visibility(container, single, tk)
keep_comment = true
when "attr"
parse_attr(container, single, tk, comment)
when /^attr_(reader|writer|accessor)$/, @options.extra_accessors
parse_attr_accessor(container, single, tk, comment)
when "alias_method"
if container.document_self
parse_alias(container, single, tk, comment)
end
end
end
case tk.name
when "require"
parse_require(container, comment)
when "include"
parse_include(container, comment)
end
when TkEND
nest -= 1
puts "Found 'end' in #{container.name}, nest = #{nest}, line #{tk.line_no}" if $DEBUG
puts "Method = #{current_method.name}" if $DEBUG and current_method
if nest == 0
read_documentation_modifiers(container, CLASS_MODIFIERS)
container.ongoing_visibility = save_visibility
return
end
end
comment = '' unless keep_comment
begin
get_tkread
skip_tkspace(false)
end while peek_tk == TkNL
end
end