99from typing import Any , Optional , Union
1010
1111from pydantic import AnyUrl , BaseModel
12+ from typing_extensions import deprecated
1213
1314from docling_core .types .doc .document import (
1415 DocItem ,
@@ -258,6 +259,7 @@ def serialize_captions(
258259 """Serialize the item's captions."""
259260 ...
260261
262+ @deprecated ("Use serialize_meta() instead." )
261263 @abstractmethod
262264 def serialize_annotations (
263265 self ,
@@ -267,6 +269,15 @@ def serialize_annotations(
267269 """Serialize the item's annotations."""
268270 ...
269271
272+ @abstractmethod
273+ def serialize_meta (
274+ self ,
275+ item : NodeItem ,
276+ ** kwargs : Any ,
277+ ) -> SerializationResult :
278+ """Serialize the item's meta."""
279+ ...
280+
270281 @abstractmethod
271282 def get_excluded_refs (self , ** kwargs : Any ) -> set [str ]:
272283 """Get references to excluded items."""
@@ -287,6 +298,26 @@ def get_serializer(self, doc: DoclingDocument) -> BaseDocSerializer:
287298 ...
288299
289300
301+ class BaseMetaSerializer (ABC ):
302+ """Base class for meta serializers."""
303+
304+ @abstractmethod
305+ def serialize (
306+ self ,
307+ * ,
308+ item : NodeItem ,
309+ doc : DoclingDocument ,
310+ ** kwargs : Any ,
311+ ) -> SerializationResult :
312+ """Serializes the meta of the passed item."""
313+ ...
314+
315+ def _humanize_text (self , text : str , title : bool = False ) -> str :
316+ tmp = text .replace ("__" , "_" ).replace ("_" , " " )
317+ return tmp .title () if title else tmp .capitalize ()
318+
319+
320+ @deprecated ("Use BaseMetaSerializer() instead." )
290321class BaseAnnotationSerializer (ABC ):
291322 """Base class for annotation serializers."""
292323
0 commit comments