human
Complete this python program:
def copy_function_doc_to_method_doc(source):
assistant
#Here is the Python code you requested.

    """Use the docstring from a function as docstring for a method.
    The docstring of the source function is prepepended to the docstring of the
    function wrapped by this decorator. Additionally, the first parameter
    specified in the docstring of the source function is removed in the new
    docstring.
    This decorator is useful when implementing a method that just calls a
    function.  This pattern is prevalent in for example the plotting functions
    of MNE.
    Parameters
    source : function
    Function to copy the docstring from
    Returns
    wrapper : function
    The decorated method
    Examples
    >>> def plot_function(object, a, b):
    ...     \\\Docstring for plotting function.
    ...     Parameters
    ...     object : instance of object
    ...         The object to plot
    ...     a : int
    ...         Some parameter
    ...     b : int
    ...         Some parameter
    ...     pass
    >>> class A:
    ...     @copy_function_doc_to_method_doc(plot_function)
    ...     def plot(self, a, b):
    ...         Notes
    ...         .. versionadded:: 0.13.0
    ...         plot_function(self, a, b)
    >>> print(A.plot.__doc__)
    Docstring for plotting function.
    <BLANKLINE>
    Parameters
    a : int
    Some parameter
    b : int
    Some parameter
    <BLANKLINE>
    Notes
    .. versionadded:: 0.13.0
    <BLANKLINE>
    Notes
    The parsing performed is very basic and will break easily on docstrings
    that are not formatted exactly according to the ``numpydoc`` standard.
    Always inspect the resulting docstring when using this decorator.
    """
    def wrapper(func):
        doc = source.__doc__.split('\n')
        for (line, text) in enumerate(doc[:(-2)]):
            if ((text.strip() == 'Parameters') and (doc[(line + 1)].strip() == '----------')):
                parameter_block = line
                break
        else:
            raise ValueError('Cannot    copy    function    docstring:    no    parameter    block    found.    To    simply    copy    the    docstring,    use    the    @copy_doc    decorator    instead.')
        for (line, text) in enumerate(doc[parameter_block:], parameter_block):
            if (':' in text):
                first_parameter = line
                parameter_indentation = (len(text) - len(text.lstrip('    ')))
                break
        else:
            raise ValueError('Cannot    copy    function    docstring:    no    parameters    found.    To    simply    copy    the    docstring,    use    the    @copy_doc    decorator    instead.')
        for (line, text) in enumerate(doc[(first_parameter + 1):], (first_parameter + 1)):
            if (len(text.strip()) == 0):
                continue
            line_indentation = (len(text) - len(text.lstrip('    ')))
            if (line_indentation <= parameter_indentation):
                first_parameter_end = line
                if (':' not in text):
                    first_parameter = parameter_block
                break
        else:
            first_parameter_end = line
            first_parameter = parameter_block
        doc = (('\n'.join(doc[:first_parameter]) + '\n') + '\n'.join(doc[first_parameter_end:]))
        if (func.__doc__ is not None):
            doc += func.__doc__
        func.__doc__ = doc
        return func
    return wrapper