docs: def trace(self, func):
          """Decorator to print out a function's arguments and return value."""
  
          def wrapper(*args, **kwargs):
              # Print out the call to the function with its arguments.
              s = self.Stanza(self.indent)
              s.add([self.GREEN, func.__name__, self.NORMAL, '('])
              s.indent += 4
              sep = ''
              for arg in args:
                  s.add([self.CYAN, self.safe_repr(arg), self.NORMAL], sep)
                  sep = ', '
              for name, value in sorted(kwargs.items()):
                  s.add([name + '=', self.CYAN, self.safe_repr(value),
                         self.NORMAL], sep)
                  sep = ', '
              s.add(')', wrap=False)
              self.writer.write(s.chunks)
  
              # Call the function.
              self.indent += 2
              try:
                  result = func(*args, **kwargs)
              except:
                  # Display an exception.
                  self.indent -= 2
                  etype, evalue, etb = self.sys.exc_info()
                  info = self.inspect.getframeinfo(etb.tb_next, context=3)
                  s = self.Stanza(self.indent)
                  s.add([self.RED, '!> ', self.safe_repr(evalue), self.NORMAL])
                  s.add(['at ', info.filename, ':', info.lineno], ' ')
                  lines = self.unindent(info.code_context)
                  firstlineno = info.lineno - info.index
                  fmt = '%' + str(len(str(firstlineno + len(lines)))) + 'd'
                  for i, line in enumerate(lines):
                      s.newline()
                      s.add([
                          i == info.index and self.MAGENTA or '',
                          fmt % (i + firstlineno),
                          i == info.index and '> ' or ': ', line, self.NORMAL])
                  self.writer.write(s.chunks)
                  raise
  
              # Display the return value.
              self.indent -= 2
              s = self.Stanza(self.indent)
              s.add([self.GREEN, '-> ', self.CYAN, self.safe_repr(result),
                     self.NORMAL])
              self.writer.write(s.chunks)
              return result
          return self.functools.update_wrapper(wrapper, func)