docs: def encode_collection(collection):
      """Encode a single collection."""
      tree = etree.Element('collection')
      etree.SubElement(tree, 'source').text = collection.source
      etree.SubElement(tree, 'date').text = collection.date
      etree.SubElement(tree, 'key').text = collection.key
      encode_infons(tree, collection.infons)
      for doc in collection.documents:
          tree.append(encode_document(doc))
      return tree