import textwrap


def get_docstring(target) -> str:
    """
    Retrieves the documentation string from the target object and returns it
    after removing insignificant whitespace

    :param target:
        The object for which the doc string should be retrieved
    :return:
        The cleaned documentation string for the target. If no doc string
        exists an empty string will be returned instead.
    """

    raw = getattr(target, '__doc__')

    if raw is None:
        return ''

    return textwrap.dedent(raw)