code: def borrowkwargs(cls=None, methodname=None, exclude=None):
      """Return  a decorator which would borrow docstring for ``**kwargs``
  
      Notes
      -----
      TODO: take care about ``*args`` in  a clever way if those are also present
  
      Examples
      --------
      In the simplest scenario -- just grab all arguments from parent class::
  
             @borrowkwargs(A)
             def met1(self, desc, **kwargs):
                 pass
  
      Parameters
      ----------
      methodname : None or str
        Name of the method from which to borrow.  If None, would use
        the same name as of the decorated method
      exclude : None or list of arguments to exclude
        If function does not pass all ``**kwargs``, you would need to list
        those here to be excluded from borrowed docstring
      """
  
      def _borrowkwargs(method):
          """Decorator which borrows docstrings for ``**kwargs`` for the `method`"""
          if cls:
              if methodname is None:
                  other_method = getattr(cls, method.__name__)
              else:
                  other_method = getattr(cls, methodname)
          elif methodname:
              other_method = methodname
  
          # TODO:
          # method.__doc__ = enhanced_from(other_method.__doc__)
  
          mdoc, odoc = method.__doc__, other_method.__doc__
          if mdoc is None:
              mdoc = ""
  
          mpreamble, mparams, msuffix = _split_out_parameters(mdoc)
          opreamble, oparams, osuffix = _split_out_parameters(odoc)
          mplist = _parse_parameters(mparams)
          oplist = _parse_parameters(oparams)
          known_params = set([i[0] for i in mplist])
  
          # !!! has to not rebind exclude variable
          skip_params = exclude or []  # handle None
          skip_params = set(["kwargs", "**kwargs"] + skip_params)
  
          # combine two and filter out items to skip
          aplist = [i for i in mplist if not i[0] in skip_params]
          aplist += [
              i
              for i in oplist
              if not i[0] in skip_params.union(known_params)
          ]
  
          docstring = mpreamble
          if len(aplist):
              params_ = "\n".join([i[1].rstrip() for i in aplist])
              docstring += "\n\n%s\n" % _rst_section(
                  "Parameters"
              ) + _indent(params_)
  
          if msuffix != "":
              docstring += "\n\n" + msuffix
  
          docstring = handle_docstring(docstring)
  
          # Finally assign generated doc to the method
          method.__doc__ = docstring
          return method
  
      return _borrowkwargs
  
file_path: datalad/datalad/dochelpers.py
imports: import logging
  import re
  import textwrap
  import os
  import sys
  import traceback
  from datalad.support.exceptions import CapturedException
label_desc: Use image node_id 10 for calling a global function with example usage: borrowkwargs(cls, methodname, exclude) and returns: _borrowkwargs, method