docs: def handle_document(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
          """Handle statements like ``SET DOCUMENT X = "Y"``.
  
          :raises: InvalidMetadataException
          :raises: VersionFormatWarning
          """
          key = tokens['key']
          value = tokens['value']
  
          if key not in DOCUMENT_KEYS:
              raise InvalidMetadataException(self.get_line_number(), line, position, key, value)
  
          norm_key = DOCUMENT_KEYS[key]
  
          if norm_key in self.document_metadata:
              log.warning('Tried to overwrite metadata: %s', key)
              return tokens
  
          self.document_metadata[norm_key] = value
  
          if norm_key == METADATA_VERSION:
              self.raise_for_version(line, position, value)
  
          return tokens