import textwrap


def dedent_docstring(text):
    """Dedent typical python doc string.

    Parameters
    ----------
    text : str
        string, typically something like ``func.__doc__``.

    Returns
    -------
    str
        string with the leading common whitespace removed from each
        line

    See Also
    --------
    textwrap.dedent


    .. versionadded:: 0.19.0
    """
    lines = text.splitlines()
    if len(lines) < 2:
        return text.lstrip()

    # treat first line as special (typically no leading whitespace!) which messes up dedent
    return lines[0].lstrip() + "\n" + textwrap.dedent("\n".join(lines[1:]))