def handle_constants(type, var_name, const_name, definition)
class_name = @known_classes[var_name]
return unless class_name
class_obj = find_class var_name, class_name
unless class_obj then
@options.warn "Enclosing class/module #{const_name.inspect} not known"
return
end
comment = find_const_comment type, const_name, class_name
comment.normalize
if type.downcase == 'const' then
elements = comment.text.split ':'
if elements.nil? or elements.empty? then
con = RDoc::Constant.new const_name, definition, comment
else
new_definition = elements[0..-2].join(':')
if new_definition.empty? then
new_definition = definition
else
new_definition.gsub!("\:", ":")
new_definition.gsub!("\\", '\\')
end
new_definition.sub!(/\A(\s+)/, '')
new_comment = if $1.nil? then
elements.last.lstrip
else
"#{$1}#{elements.last.lstrip}"
end
new_comment = RDoc::Comment.new new_comment, @top_level
con = RDoc::Constant.new const_name, new_definition, new_comment
end
else
con = RDoc::Constant.new const_name, definition, comment
end
con.record_location @top_level
@stats.add_constant con
class_obj.add_constant con
end