def autodocument_from_superclasses(cls):
    """Fill in missing documentation on overridden methods.

    Can be used as a class decorator.
    """
    undocumented = []
    for name, attribute in cls.__dict__.items():
        # is it a method on the class that is locally undocumented?
        if hasattr(attribute, '__call__') and not attribute.__doc__:
            # don't muck with builtins
            if not hasattr(attribute, '__module__'):
                continue
            # find docs on a superclass
            for supercls in cls.__bases__:
                try:
                    superdoc = getattr(supercls, name).__doc__
                    if superdoc:
                        setattr(attribute, '__doc__', superdoc)
                        break
                except (AttributeError, TypeError):
                    pass
    return cls


# derived from SQLAlchemy (http://www.sqlalchemy.org/); MIT License
dataset/ETHPy150Open jek/flatland/flatland/util/base.py/autodocument_from_superclasses/original