docs: def mapper(class_, local_table=None, id_attribute='id', slug_expression=None,
             *args, **kwargs):
      """
      Convenience wrapper around the SA mapper which will set up the hybrid
      "id" and "slug" attributes required by everest after calling the SA
      mapper.
  
      If you (e.g., for testing purposes) want to clear mappers created with
      this function, use the :func:`clear_mappers` function in this module.
  
      :param str id_attribute: the name of the column in the table to use as
        ID column (will be aliased to a new "id" attribute in the mapped class)
      :param slug_expression: function to generate a slug SQL expression given
        the mapped class as argument.
      """
      mpr = sa_mapper(class_, local_table=local_table, *args, **kwargs)
      # Set up the ID attribute as a hybrid property, if necessary.
      if id_attribute != 'id':
          # Make sure we are not overwriting an already mapped or customized
          # 'id' attribute.
          if 'id' in mpr.columns:
              mpr.dispose()
              raise ValueError('Attempting to overwrite the mapped "id" '
                               'attribute.')
          elif isdatadescriptor(getattr(class_, 'id', None)):
              mpr.dispose()
              raise ValueError('Attempting to overwrite the custom data '
                               'descriptor defined for the "id" attribute.')
          class_.id = synonym(id_attribute)
      # If this is a polymorphic class, a base class may already have a
      # hybrid descriptor set as slug attribute.
      slug_descr = None
      for base_cls in class_.__mro__:
          try:
              slug_descr = object.__getattribute__(base_cls, 'slug')
          except AttributeError:
              pass
          else:
              break
      if isinstance(slug_descr, hybrid_descriptor):
          if not slug_expression is None:
              raise ValueError('Attempting to overwrite the expression for '
                               'an inherited slug hybrid descriptor.')
          hyb_descr = slug_descr
      else:
          # Set up the slug attribute as a hybrid property.
          if slug_expression is None:
              cls_expr = lambda cls: cast(getattr(cls, 'id'), String)
          else:
              cls_expr = slug_expression
          hyb_descr = hybrid_descriptor(slug_descr, expr=cls_expr)
      class_.slug = hyb_descr
      return mpr