code: def borrowdoc(cls, methodname=None):
      """Return a decorator to borrow docstring from another `cls`.`methodname`
  
      It should not be used for __init__ methods of classes derived from
      ClassWithCollections since __doc__'s of those are handled by the
      AttributeCollector anyways.
  
      Common use is to borrow a docstring from the class's method for an
      adapter function (e.g. sphere_searchlight borrows from Searchlight)
  
      Examples
      --------
      To borrow `__repr__` docstring from parent class `Mapper`, do::
  
         @borrowdoc(Mapper)
         def __repr__(self):
             ...
  
      Parameters
      ----------
      cls
        Usually a parent class
      methodname : None or str
        Name of the method from which to borrow.  If None, would use
        the same name as of the decorated method
      """
  
      def _borrowdoc(method):
          """Decorator which assigns to the `method` docstring from another"""
          if methodname is None:
              other_method = getattr(cls, method.__name__)
          else:
              other_method = getattr(cls, methodname)
          if hasattr(other_method, "__doc__"):
              method.__doc__ = other_method.__doc__
          return method
  
      return _borrowdoc
  
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 9 for calling a global function with example usage: borrowdoc(cls, methodname) and returns: _borrowdoc, method