Skip to content

Commit e9a5648

Browse files
Merge pull request #420 from adamtheturtle/debug
Add annotations to mention
2 parents 90f0a3f + fc0fee7 commit e9a5648

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

src/sphinx_notion/__init__.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
from ultimate_notion.obj_api.core import ObjectRef, UserRef
8282
from ultimate_notion.obj_api.enums import BGColor, CodeLang, Color
8383
from ultimate_notion.obj_api.objects import (
84+
Annotations,
8485
DateRange,
8586
MentionDatabase,
8687
MentionDate,
@@ -518,7 +519,10 @@ def _(node: _MentionUserNode) -> Text:
518519
"""
519520
user_id = node.attributes["user_id"]
520521
user_ref = UserRef(id=user_id)
521-
mention_obj = MentionUser.build_mention_from(user=user_ref)
522+
mention_obj = MentionUser.build_mention_from(
523+
user=user_ref,
524+
style=Annotations(),
525+
)
522526
return Text.wrap_obj_ref(obj_refs=[mention_obj])
523527

524528

@@ -530,7 +534,10 @@ def _(node: _MentionPageNode) -> Text:
530534
"""
531535
page_id = node.attributes["page_id"]
532536
page_obj_ref = ObjectRef(id=page_id)
533-
mention_obj = MentionPage.build_mention_from(page=page_obj_ref)
537+
mention_obj = MentionPage.build_mention_from(
538+
page=page_obj_ref,
539+
style=Annotations(),
540+
)
534541
return Text.wrap_obj_ref(obj_refs=[mention_obj])
535542

536543

@@ -542,7 +549,10 @@ def _(node: _MentionDatabaseNode) -> Text:
542549
"""
543550
database_id = node.attributes["database_id"]
544551
database_obj_ref = ObjectRef(id=database_id)
545-
mention_obj = MentionDatabase.build_mention_from(db=database_obj_ref)
552+
mention_obj = MentionDatabase.build_mention_from(
553+
db=database_obj_ref,
554+
style=Annotations(),
555+
)
546556
return Text.wrap_obj_ref(obj_refs=[mention_obj])
547557

548558

@@ -555,7 +565,10 @@ def _(node: _MentionDateNode) -> Text:
555565
parsed_date = node.attributes["date"]
556566
date_range = DateRange.build(dt_spec=parsed_date)
557567

558-
mention_obj = MentionDate.build_mention_from(date_range=date_range)
568+
mention_obj = MentionDate.build_mention_from(
569+
date_range=date_range,
570+
style=Annotations(),
571+
)
559572
return Text.wrap_obj_ref(obj_refs=[mention_obj])
560573

561574

tests/test_integration.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
from ultimate_notion.obj_api.core import ObjectRef, UserRef
5959
from ultimate_notion.obj_api.enums import BGColor, CodeLang, Color
6060
from ultimate_notion.obj_api.objects import (
61+
Annotations,
6162
DateRange,
6263
MentionDatabase,
6364
MentionDate,
@@ -3336,7 +3337,11 @@ def test_notion_mention_user(
33363337
"""
33373338

33383339
user_ref = UserRef(id=UUID(hex=test_user_id))
3339-
mention_obj = MentionUser.build_mention_from(user=user_ref)
3340+
mention_obj = MentionUser.build_mention_from(
3341+
user=user_ref,
3342+
# We require annotations else the equivalence check later will fail.
3343+
style=Annotations(),
3344+
)
33403345
expected_blocks = [
33413346
UnoParagraph(
33423347
text=text(text="Hello ")
@@ -3368,7 +3373,10 @@ def test_notion_mention_page(
33683373
"""
33693374

33703375
page_obj_ref = ObjectRef(id=UUID(hex=test_page_id))
3371-
mention_obj = MentionPage.build_mention_from(page=page_obj_ref)
3376+
mention_obj = MentionPage.build_mention_from(
3377+
page=page_obj_ref,
3378+
style=Annotations(),
3379+
)
33723380
expected_blocks = [
33733381
UnoParagraph(
33743382
text=text(text="See ")
@@ -3400,7 +3408,10 @@ def test_notion_mention_database(
34003408
"""
34013409

34023410
database_obj_ref = ObjectRef(id=UUID(hex=test_database_id))
3403-
mention_obj = MentionDatabase.build_mention_from(db=database_obj_ref)
3411+
mention_obj = MentionDatabase.build_mention_from(
3412+
db=database_obj_ref,
3413+
style=Annotations(),
3414+
)
34043415
expected_blocks = [
34053416
UnoParagraph(
34063417
text=text(text="Check the ")
@@ -3433,7 +3444,10 @@ def test_notion_mention_date(
34333444

34343445
parsed_date = dt.date.fromisoformat(test_date)
34353446
date_range = DateRange.build(dt_spec=parsed_date)
3436-
mention_obj = MentionDate.build_mention_from(date_range=date_range)
3447+
mention_obj = MentionDate.build_mention_from(
3448+
date_range=date_range,
3449+
style=Annotations(),
3450+
)
34373451
expected_blocks = [
34383452
UnoParagraph(
34393453
text=text(text="The meeting is on ")

0 commit comments

Comments
 (0)