From ae2f1317255938d102c716efaf2db6adbc724bd1 Mon Sep 17 00:00:00 2001 From: Christoph Auer <60343111+cau-git@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:39:07 +0100 Subject: [PATCH] fix: Hotfix for TableItem.export_to_html args (#76) Signed-off-by: Christoph Auer --- docling_core/types/doc/document.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docling_core/types/doc/document.py b/docling_core/types/doc/document.py index 040c0b4..828dcf4 100644 --- a/docling_core/types/doc/document.py +++ b/docling_core/types/doc/document.py @@ -10,6 +10,7 @@ import sys import textwrap import typing +import warnings from io import BytesIO from pathlib import Path from typing import Any, Dict, Final, List, Literal, Optional, Tuple, Union @@ -1008,14 +1009,23 @@ def export_to_markdown(self) -> str: ) return md_table - def export_to_html(self, doc: "DoclingDocument", add_caption: bool = True) -> str: + def export_to_html( + self, doc: Optional["DoclingDocument"] = None, add_caption: bool = True + ) -> str: """Export the table as html.""" + if doc is None: + warnings.warn( + "The `doc` argument will be mandatory in a future version. " + "It must be provided to include a caption.", + DeprecationWarning, + ) + body = "" nrows = self.data.num_rows ncols = self.data.num_cols text = "" - if add_caption and len(self.captions): + if doc is not None and add_caption and len(self.captions): text = self.caption_text(doc) if len(self.data.table_cells) == 0: