import inspect


def get_member_names(obj):
    """Return all members names of the given object"""
    if inspect.ismodule(obj):
        if hasattr(obj, "__all__"):
            return obj.__all__

        return [
            k
            for k, v in vars(obj).items()
            if (
                getattr(v, "__module__", None) == obj.__name__
                and getattr(v, "__doc__", None) is not None
                and not k.startswith("_")
            )
        ]

    elif inspect.isclass(obj):
        if hasattr(obj, "__members__"):
            return obj.__members__

        return [
            k
            for k, v in vars(obj).items()
            if (
                callable(v)
                and getattr(v, "__doc__", None) is not None
                and not k.startswith("_")
            )
        ]

    else:
        raise ValueError(f"cannot get members of {obj!r}")