method
parse_constant
v1_9_2_180 -
Show latest stable
- Class:
RDoc::Parser::Ruby
parse_constant(container, tk, comment)public
No documentation available.
# File lib/rdoc/parser/ruby.rb, line 591
def parse_constant(container, tk, comment)
name = tk.name
skip_tkspace false
eq_tk = get_tk
unless TkASSIGN === eq_tk then
unget_tk eq_tk
return
end
nest = 0
get_tkread
tk = get_tk
if TkGT === tk then
unget_tk tk
unget_tk eq_tk
return
end
rhs_name = ''
loop do
case tk
when TkSEMICOLON then
break
when TkLPAREN, TkfLPAREN, TkLBRACE, TkLBRACK, TkDO, TkIF, TkUNLESS,
TkCASE then
nest += 1
when TkRPAREN, TkRBRACE, TkRBRACK, TkEND then
nest -= 1
when TkCOMMENT then
if nest <= 0 && @scanner.lex_state == EXPR_END
unget_tk tk
break
end
when TkCONSTANT then
rhs_name << tk.name
if nest <= 0 and TkNL === peek_tk then
mod = if rhs_name =~ /^::/ then
RDoc::TopLevel.find_class_or_module rhs_name
else
container.find_module_named rhs_name
end
container.add_module_alias mod, name if mod
get_tk # TkNL
break
end
when TkNL then
if nest <= 0 &&
(@scanner.lex_state == EXPR_END || [email protected]) then
unget_tk tk
break
end
when TkCOLON2, TkCOLON3 then
rhs_name << '::'
when nil then
break
end
tk = get_tk
end
res = get_tkread.tr("\n", " ").strip
res = "" if res == ";"
con = RDoc::Constant.new name, res, comment
read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS
@stats.add_constant con
container.add_constant con if con.document_self
end