docs: def end_state(self):
          """
          Wrap things up and add any final string content.
          """
  
          # Make sure we append any trailing text
          if self.str_begin != len(self.format):
              if len(self.state) > 1 or self.state[-1] != 'string':
                  self.fmt.append_text(
                      "(Bad format string; ended in state %r)" % self.state[-1])
              else:
                  self.fmt.append_text(self.format[self.str_begin:])
  
          # Convenience return
          return self.fmt