import re


def since(version):
    """A decorator that annotates a function to append the version 
    of skutil the function was added. This decorator is an adaptation of PySpark's.

    Parameters
    ----------

    version : str, float or int
        The version the specified method was added to skutil.


    Examples
    --------

        >>> @since('0.1.5')
        ... def some_fun():
        ...     '''Some docstring'''
        ...     return None
        ...
        >>>
        >>> some_fun.__doc__ # doctest: +SKIP
        'Some docstring\n\n.. versionadded:: 0.1.5'


    .. versionadded:: 0.1.5
    """
    indent_p = re.compile(r'\n( +)')

    def deco(f):
        indents = indent_p.findall(f.__doc__)
        indent = ' ' * (min(len(m) for m in indents) if indents else 0)
        f.__doc__ = f.__doc__.rstrip() + "\n\n%s.. versionadded:: %s" % (indent, version)
        return f

    return deco