docs: def hook(self, name):
          """ Return a decorator that attaches a callback to a hook. See
              :meth:`add_hook` for details."""
          def decorator(func):
              self.add_hook(name, func)
              return func
          return decorator