docs: def extend(klass, name=None):
      '''A function decorator for extending an existing class.
  
      Use as a decorator for functions to add to an existing class.
  
      Args:
          klass: The class to be decorated.
  
          name: The name the new method is to be given in the klass class.
  
      Returns:
          A decorator function which accepts a single function as its only
          argument.  The decorated function will be added to class klass.
  
      Raises:
          ValueError: If klass already has an attribute with the same name as the
              extension method.
      '''
      def decorator(f):
          return add_method(f, klass, name)
  
      return decorator