Skip to content

Commit bfb8fe7

Browse files
committed
Put line number in multiple header row error
1 parent c104c3e commit bfb8fe7

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/sphinx_notion/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,19 @@ def _(
473473
table_structure = _extract_table_structure(node=node)
474474

475475
if len(table_structure.header_rows) > 1:
476+
first_header_row = table_structure.header_rows[0]
477+
first_header_row_entry = first_header_row.children[0]
478+
first_header_row_paragraph = first_header_row_entry.children[0]
479+
first_header_row_line = first_header_row_paragraph.line
480+
last_header_row = table_structure.header_rows[-1]
481+
last_header_row_entry = last_header_row.children[0]
482+
last_header_row_paragraph = last_header_row_entry.children[0]
483+
last_header_row_line = last_header_row_paragraph.line
476484
table_multiple_header_rows_msg = (
477-
"Tables with multiple header rows are not supported."
485+
"Tables with multiple header rows are not supported. "
486+
f"First header row is on line {first_header_row_line} in "
487+
f"{first_header_row_paragraph.source}, last header row is on "
488+
f"line {last_header_row_line}"
478489
)
479490
raise ValueError(table_multiple_header_rows_msg)
480491

tests/test_integration.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,12 @@ def test_list_table_header_maximum_one_allowed(
18261826
- Cell a 2
18271827
"""
18281828

1829-
expected_message = r"^Tables with multiple header rows are not supported.$"
1829+
expected_message = (
1830+
r"^Tables with multiple header rows are not supported. "
1831+
r"First header row is on line 4 in "
1832+
rf"{re.escape(pattern=str(object=tmp_path / 'src' / 'index.rst'))}, "
1833+
r"last header row is on line 6"
1834+
)
18301835
with pytest.raises(expected_exception=ValueError, match=expected_message):
18311836
_assert_rst_converts_to_notion_objects(
18321837
rst_content=rst_content,

0 commit comments

Comments
 (0)