code: def copy_function_doc_to_method_doc(source):
      """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.
  
      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.
  
      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>
      """  # noqa: D410, D411, D214, D215
  
      def wrapper(func):
          doc = source.__doc__.split("\n")
          if len(doc) == 1:
              doc = doc[0]
              if func.__doc__ is not None:
                  doc += func.__doc__
              func.__doc__ = doc
              return func
  
          # Find parameter block
          for line, text in enumerate(doc[:-2]):
              if (
                  text.strip() == "Parameters"
                  and doc[line + 1].strip() == "----------"
              ):
                  parameter_block = line
                  break
          else:
              # No parameter block found
              raise ValueError(
                  "Cannot copy function docstring: no parameter "
                  "block found. To simply copy the docstring, use "
                  "the @copy_doc decorator instead."
              )
  
          # Find first parameter
          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."
              )
  
          # Find end of first parameter
          for line, text in enumerate(
              doc[first_parameter + 1 :], first_parameter + 1
          ):
              # Ignore empty lines
              if len(text.strip()) == 0:
                  continue
  
              line_indentation = len(text) - len(text.lstrip(" "))
              if line_indentation <= parameter_indentation:
                  # Reach end of first parameter
                  first_parameter_end = line
  
                  # Of only one parameter is defined, remove the Parameters
                  # heading as well
                  if ":" not in text:
                      first_parameter = parameter_block
  
                  break
          else:
              # End of docstring reached
              first_parameter_end = line
              first_parameter = parameter_block
  
          # Copy the docstring, but remove the first parameter
          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
  
imports: import inspect
  import os
  import os.path
  import re
  import sys
  import webbrowser
  from copy import deepcopy
  from decorator import FunctionMaker
  from ..defaults import HEAD_SIZE_DEFAULT
  from ._bunch import BunchConst
label_desc: Use image node_id 4 for calling a global function with example usage: copy_function_doc_to_method_doc(source) and returns: wrapper, func, func