class RDoc::Context

def add_class(class_type, name, superclass = 'Object')

def add_class(class_type, name, superclass = 'Object')
  klass = add_class_or_module @classes, class_type, name, superclass
  existing = klass.superclass
  existing = existing.name if existing and not String === existing
  if superclass != existing and superclass != 'Object' then
    klass.superclass = superclass
  end
  # If the parser encounters Container::Item before encountering
  # Container, then it assumes that Container is a module.  This may not
  # be the case, so remove Container from the module list if present and
  # transfer any contained classes and modules to the new class.
  mod = RDoc::TopLevel.modules_hash.delete klass.full_name
  if mod then
    klass.classes_hash.update mod.classes_hash
    klass.modules_hash.update mod.modules_hash
    klass.method_list.concat mod.method_list
    @modules.delete klass.name
  end
  RDoc::TopLevel.classes_hash[klass.full_name] = klass
  klass
end