notionary 0.2.19__py3-none-any.whl → 0.2.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. notionary/__init__.py +8 -4
  2. notionary/base_notion_client.py +3 -1
  3. notionary/blocks/__init__.py +2 -91
  4. notionary/blocks/_bootstrap.py +263 -0
  5. notionary/blocks/audio/__init__.py +8 -2
  6. notionary/blocks/audio/audio_element.py +42 -104
  7. notionary/blocks/audio/audio_markdown_node.py +3 -1
  8. notionary/blocks/audio/audio_models.py +6 -55
  9. notionary/blocks/base_block_element.py +30 -0
  10. notionary/blocks/bookmark/__init__.py +9 -2
  11. notionary/blocks/bookmark/bookmark_element.py +46 -139
  12. notionary/blocks/bookmark/bookmark_markdown_node.py +3 -1
  13. notionary/blocks/bookmark/bookmark_models.py +15 -0
  14. notionary/blocks/breadcrumbs/__init__.py +17 -0
  15. notionary/blocks/breadcrumbs/breadcrumb_element.py +39 -0
  16. notionary/blocks/breadcrumbs/breadcrumb_markdown_node.py +32 -0
  17. notionary/blocks/breadcrumbs/breadcrumb_models.py +12 -0
  18. notionary/blocks/bulleted_list/__init__.py +12 -2
  19. notionary/blocks/bulleted_list/bulleted_list_element.py +40 -55
  20. notionary/blocks/bulleted_list/bulleted_list_markdown_node.py +2 -1
  21. notionary/blocks/bulleted_list/bulleted_list_models.py +18 -0
  22. notionary/blocks/callout/__init__.py +9 -2
  23. notionary/blocks/callout/callout_element.py +40 -89
  24. notionary/blocks/callout/callout_markdown_node.py +3 -1
  25. notionary/blocks/callout/callout_models.py +33 -0
  26. notionary/blocks/child_database/__init__.py +7 -0
  27. notionary/blocks/child_database/child_database_models.py +19 -0
  28. notionary/blocks/child_page/__init__.py +9 -0
  29. notionary/blocks/child_page/child_page_models.py +12 -0
  30. notionary/blocks/{shared/block_client.py → client.py} +55 -54
  31. notionary/blocks/code/__init__.py +6 -2
  32. notionary/blocks/code/code_element.py +53 -187
  33. notionary/blocks/code/code_markdown_node.py +13 -13
  34. notionary/blocks/code/code_models.py +94 -0
  35. notionary/blocks/column/__init__.py +25 -1
  36. notionary/blocks/column/column_element.py +40 -314
  37. notionary/blocks/column/column_list_element.py +37 -0
  38. notionary/blocks/column/column_list_markdown_node.py +50 -0
  39. notionary/blocks/column/column_markdown_node.py +59 -0
  40. notionary/blocks/column/column_models.py +26 -0
  41. notionary/blocks/divider/__init__.py +9 -2
  42. notionary/blocks/divider/divider_element.py +26 -49
  43. notionary/blocks/divider/divider_markdown_node.py +2 -1
  44. notionary/blocks/divider/divider_models.py +12 -0
  45. notionary/blocks/embed/__init__.py +9 -2
  46. notionary/blocks/embed/embed_element.py +47 -114
  47. notionary/blocks/embed/embed_markdown_node.py +3 -1
  48. notionary/blocks/embed/embed_models.py +14 -0
  49. notionary/blocks/equation/__init__.py +14 -0
  50. notionary/blocks/equation/equation_element.py +80 -0
  51. notionary/blocks/equation/equation_element_markdown_node.py +36 -0
  52. notionary/blocks/equation/equation_models.py +11 -0
  53. notionary/blocks/file/__init__.py +25 -0
  54. notionary/blocks/file/file_element.py +93 -0
  55. notionary/blocks/file/file_element_markdown_node.py +35 -0
  56. notionary/blocks/file/file_element_models.py +39 -0
  57. notionary/blocks/heading/__init__.py +16 -2
  58. notionary/blocks/heading/heading_element.py +67 -72
  59. notionary/blocks/heading/heading_markdown_node.py +2 -1
  60. notionary/blocks/heading/heading_models.py +29 -0
  61. notionary/blocks/image_block/__init__.py +13 -0
  62. notionary/blocks/image_block/image_element.py +84 -0
  63. notionary/blocks/{image → image_block}/image_markdown_node.py +3 -1
  64. notionary/blocks/image_block/image_models.py +10 -0
  65. notionary/blocks/models.py +172 -0
  66. notionary/blocks/numbered_list/__init__.py +12 -2
  67. notionary/blocks/numbered_list/numbered_list_element.py +33 -58
  68. notionary/blocks/numbered_list/numbered_list_markdown_node.py +3 -1
  69. notionary/blocks/numbered_list/numbered_list_models.py +17 -0
  70. notionary/blocks/paragraph/__init__.py +12 -2
  71. notionary/blocks/paragraph/paragraph_element.py +27 -69
  72. notionary/blocks/paragraph/paragraph_markdown_node.py +2 -1
  73. notionary/blocks/paragraph/paragraph_models.py +16 -0
  74. notionary/blocks/pdf/__init__.py +13 -0
  75. notionary/blocks/pdf/pdf_element.py +91 -0
  76. notionary/blocks/pdf/pdf_markdown_node.py +35 -0
  77. notionary/blocks/pdf/pdf_models.py +11 -0
  78. notionary/blocks/quote/__init__.py +11 -2
  79. notionary/blocks/quote/quote_element.py +31 -65
  80. notionary/blocks/quote/quote_markdown_node.py +4 -1
  81. notionary/blocks/quote/quote_models.py +18 -0
  82. notionary/blocks/registry/__init__.py +4 -0
  83. notionary/blocks/registry/block_registry.py +75 -91
  84. notionary/blocks/registry/block_registry_builder.py +107 -59
  85. notionary/blocks/rich_text/__init__.py +33 -0
  86. notionary/blocks/rich_text/rich_text_models.py +188 -0
  87. notionary/blocks/rich_text/text_inline_formatter.py +125 -0
  88. notionary/blocks/table/__init__.py +16 -2
  89. notionary/blocks/table/table_element.py +48 -241
  90. notionary/blocks/table/table_markdown_node.py +2 -1
  91. notionary/blocks/table/table_models.py +28 -0
  92. notionary/blocks/table_of_contents/__init__.py +19 -0
  93. notionary/blocks/table_of_contents/table_of_contents_element.py +51 -0
  94. notionary/blocks/table_of_contents/table_of_contents_markdown_node.py +35 -0
  95. notionary/blocks/table_of_contents/table_of_contents_models.py +18 -0
  96. notionary/blocks/todo/__init__.py +9 -2
  97. notionary/blocks/todo/todo_element.py +38 -95
  98. notionary/blocks/todo/todo_markdown_node.py +2 -1
  99. notionary/blocks/todo/todo_models.py +19 -0
  100. notionary/blocks/toggle/__init__.py +13 -3
  101. notionary/blocks/toggle/toggle_element.py +57 -264
  102. notionary/blocks/toggle/toggle_markdown_node.py +24 -14
  103. notionary/blocks/toggle/toggle_models.py +17 -0
  104. notionary/blocks/toggleable_heading/__init__.py +6 -2
  105. notionary/blocks/toggleable_heading/toggleable_heading_element.py +74 -244
  106. notionary/blocks/toggleable_heading/toggleable_heading_markdown_node.py +26 -18
  107. notionary/blocks/types.py +61 -0
  108. notionary/blocks/video/__init__.py +8 -2
  109. notionary/blocks/video/video_element.py +67 -143
  110. notionary/blocks/video/video_element_models.py +10 -0
  111. notionary/blocks/video/video_markdown_node.py +3 -1
  112. notionary/database/client.py +3 -8
  113. notionary/database/database.py +13 -14
  114. notionary/database/database_filter_builder.py +2 -2
  115. notionary/database/database_provider.py +5 -4
  116. notionary/database/models.py +337 -0
  117. notionary/database/notion_database.py +6 -7
  118. notionary/file_upload/client.py +5 -7
  119. notionary/file_upload/models.py +2 -1
  120. notionary/file_upload/notion_file_upload.py +2 -3
  121. notionary/markdown/markdown_builder.py +722 -0
  122. notionary/markdown/markdown_document_model.py +228 -0
  123. notionary/{blocks → markdown}/markdown_node.py +1 -0
  124. notionary/models/notion_database_response.py +0 -338
  125. notionary/page/client.py +9 -10
  126. notionary/page/models.py +327 -0
  127. notionary/page/notion_page.py +99 -52
  128. notionary/page/notion_text_length_utils.py +119 -0
  129. notionary/page/{content/page_content_writer.py → page_content_writer.py} +88 -38
  130. notionary/page/reader/handler/__init__.py +17 -0
  131. notionary/page/reader/handler/base_block_renderer.py +44 -0
  132. notionary/page/reader/handler/block_processing_context.py +35 -0
  133. notionary/page/reader/handler/block_rendering_context.py +43 -0
  134. notionary/page/reader/handler/column_list_renderer.py +51 -0
  135. notionary/page/reader/handler/column_renderer.py +60 -0
  136. notionary/page/reader/handler/line_renderer.py +60 -0
  137. notionary/page/reader/handler/toggle_renderer.py +69 -0
  138. notionary/page/reader/handler/toggleable_heading_renderer.py +89 -0
  139. notionary/page/reader/page_content_retriever.py +69 -0
  140. notionary/page/search_filter_builder.py +2 -1
  141. notionary/page/writer/handler/__init__.py +22 -0
  142. notionary/page/writer/handler/code_handler.py +100 -0
  143. notionary/page/writer/handler/column_handler.py +141 -0
  144. notionary/page/writer/handler/column_list_handler.py +139 -0
  145. notionary/page/writer/handler/line_handler.py +35 -0
  146. notionary/page/writer/handler/line_processing_context.py +54 -0
  147. notionary/page/writer/handler/regular_line_handler.py +92 -0
  148. notionary/page/writer/handler/table_handler.py +130 -0
  149. notionary/page/writer/handler/toggle_handler.py +153 -0
  150. notionary/page/writer/handler/toggleable_heading_handler.py +167 -0
  151. notionary/page/writer/markdown_to_notion_converter.py +76 -0
  152. notionary/telemetry/__init__.py +2 -2
  153. notionary/telemetry/service.py +4 -3
  154. notionary/user/__init__.py +2 -2
  155. notionary/user/base_notion_user.py +2 -1
  156. notionary/user/client.py +2 -3
  157. notionary/user/models.py +1 -0
  158. notionary/user/notion_bot_user.py +4 -5
  159. notionary/user/notion_user.py +3 -4
  160. notionary/user/notion_user_manager.py +3 -2
  161. notionary/user/notion_user_provider.py +1 -1
  162. notionary/util/__init__.py +3 -2
  163. notionary/util/fuzzy.py +2 -1
  164. notionary/util/logging_mixin.py +2 -2
  165. notionary/util/singleton_metaclass.py +1 -1
  166. notionary/workspace.py +3 -2
  167. {notionary-0.2.19.dist-info → notionary-0.2.21.dist-info}/METADATA +12 -8
  168. notionary-0.2.21.dist-info/RECORD +185 -0
  169. notionary/blocks/document/__init__.py +0 -7
  170. notionary/blocks/document/document_element.py +0 -102
  171. notionary/blocks/document/document_markdown_node.py +0 -31
  172. notionary/blocks/image/__init__.py +0 -7
  173. notionary/blocks/image/image_element.py +0 -151
  174. notionary/blocks/markdown_builder.py +0 -356
  175. notionary/blocks/mention/__init__.py +0 -7
  176. notionary/blocks/mention/mention_element.py +0 -229
  177. notionary/blocks/mention/mention_markdown_node.py +0 -38
  178. notionary/blocks/prompts/element_prompt_builder.py +0 -83
  179. notionary/blocks/prompts/element_prompt_content.py +0 -41
  180. notionary/blocks/shared/__init__.py +0 -0
  181. notionary/blocks/shared/models.py +0 -713
  182. notionary/blocks/shared/notion_block_element.py +0 -37
  183. notionary/blocks/shared/text_inline_formatter.py +0 -262
  184. notionary/blocks/shared/text_inline_formatter_new.py +0 -139
  185. notionary/blocks/toggleable_heading/toggleable_heading_models.py +0 -0
  186. notionary/database/models/page_result.py +0 -10
  187. notionary/elements/__init__.py +0 -0
  188. notionary/models/notion_block_response.py +0 -264
  189. notionary/models/notion_page_response.py +0 -78
  190. notionary/models/search_response.py +0 -0
  191. notionary/page/__init__.py +0 -0
  192. notionary/page/content/notion_text_length_utils.py +0 -87
  193. notionary/page/content/page_content_retriever.py +0 -60
  194. notionary/page/formatting/line_processor.py +0 -153
  195. notionary/page/formatting/markdown_to_notion_converter.py +0 -153
  196. notionary/page/markdown_syntax_prompt_generator.py +0 -114
  197. notionary/page/notion_to_markdown_converter.py +0 -179
  198. notionary/page/properites/property_value_extractor.py +0 -0
  199. notionary-0.2.19.dist-info/RECORD +0 -150
  200. /notionary/{blocks/document/document_models.py → markdown/___init__.py} +0 -0
  201. /notionary/{blocks/image/image_models.py → markdown/makdown_document_model.py} +0 -0
  202. /notionary/page/{content/markdown_whitespace_processor.py → markdown_whitespace_processor.py} +0 -0
  203. /notionary/{blocks/mention/mention_models.py → page/reader/handler/context.py} +0 -0
  204. {notionary-0.2.19.dist-info → notionary-0.2.21.dist-info}/LICENSE +0 -0
  205. {notionary-0.2.19.dist-info → notionary-0.2.21.dist-info}/WHEEL +0 -0
@@ -1,229 +0,0 @@
1
- import re
2
- from typing import Dict, Any, Optional, List
3
-
4
- from notionary.blocks import NotionBlockElement
5
- from notionary.blocks import (
6
- ElementPromptContent,
7
- ElementPromptBuilder,
8
- NotionBlockResult,
9
- )
10
-
11
-
12
- class MentionElement(NotionBlockElement):
13
- """
14
- Handles conversion between Markdown mentions and Notion mention elements.
15
-
16
- Markdown mention syntax:
17
- - @[page-id] - Mention a page by its ID
18
- - @date[YYYY-MM-DD] - Mention a date
19
- - @db[database-id] - Mention a database by its ID
20
- """
21
-
22
- MENTION_TYPES = {
23
- "page": {
24
- "pattern": r"@\[([0-9a-f-]+)\]",
25
- "create_mention": lambda id_value: {
26
- "type": "mention",
27
- "mention": {"type": "page", "page": {"id": id_value}},
28
- },
29
- "get_plain_text": lambda mention: f"Page {mention['mention']['page']['id']}",
30
- "to_markdown": lambda mention: f"@[{mention['mention']['page']['id']}]",
31
- },
32
- "date": {
33
- "pattern": r"@date\[(\d{4}-\d{2}-\d{2})\]",
34
- "create_mention": lambda date_value: {
35
- "type": "mention",
36
- "mention": {"type": "date", "date": {"start": date_value, "end": None}},
37
- },
38
- "get_plain_text": lambda mention: mention["mention"]["date"]["start"],
39
- "to_markdown": lambda mention: f"@date[{mention['mention']['date']['start']}]",
40
- },
41
- "database": {
42
- "pattern": r"@db\[([0-9a-f-]+)\]",
43
- "create_mention": lambda db_id: {
44
- "type": "mention",
45
- "mention": {"type": "database", "database": {"id": db_id}},
46
- },
47
- "get_plain_text": lambda mention: f"Database {mention['mention']['database']['id']}",
48
- "to_markdown": lambda mention: f"@db[{mention['mention']['database']['id']}]",
49
- },
50
- }
51
-
52
- @classmethod
53
- def match_markdown(cls, text: str) -> bool:
54
- """Check if text contains a markdown mention."""
55
- for mention_type in MentionElement.MENTION_TYPES.values():
56
- if re.search(mention_type["pattern"], text):
57
- return True
58
- return False
59
-
60
- @classmethod
61
- def match_notion(cls, block: Dict[str, Any]) -> bool:
62
- """Check if block contains a mention."""
63
- supported_block_types = [
64
- "paragraph",
65
- "heading_1",
66
- "heading_2",
67
- "heading_3",
68
- "bulleted_list_item",
69
- "numbered_list_item",
70
- ]
71
-
72
- if block.get("type") not in supported_block_types:
73
- return False
74
-
75
- block_content = block.get(block.get("type"), {})
76
- rich_text = block_content.get("rich_text", [])
77
-
78
- return any(text_item.get("type") == "mention" for text_item in rich_text)
79
-
80
- @classmethod
81
- def markdown_to_notion(cls, text: str) -> NotionBlockResult:
82
- """Convert markdown text with mentions to a Notion paragraph block."""
83
- if not MentionElement.match_markdown(text):
84
- return None
85
-
86
- rich_text = MentionElement._process_markdown_with_mentions(text)
87
-
88
- return {
89
- "type": "paragraph",
90
- "paragraph": {"rich_text": rich_text, "color": "default"},
91
- }
92
-
93
- @classmethod
94
- def _process_markdown_with_mentions(cls, text: str) -> List[Dict[str, Any]]:
95
- """Convert markdown mentions to Notion rich_text format."""
96
- mentions = []
97
-
98
- for mention_type, config in MentionElement.MENTION_TYPES.items():
99
- for match in re.finditer(config["pattern"], text):
100
- mentions.append(
101
- {
102
- "start": match.start(),
103
- "end": match.end(),
104
- "type": mention_type,
105
- "value": match.group(1),
106
- "original": match.group(0),
107
- }
108
- )
109
-
110
- mentions.sort(key=lambda m: m["start"])
111
-
112
- # Build rich_text list
113
- rich_text = []
114
- position = 0
115
-
116
- for mention in mentions:
117
- if mention["start"] > position:
118
- rich_text.append(
119
- MentionElement._create_text_item(text[position : mention["start"]])
120
- )
121
-
122
- # Add the mention
123
- mention_obj = MentionElement.MENTION_TYPES[mention["type"]][
124
- "create_mention"
125
- ](mention["value"])
126
-
127
- # Add annotations and plain text
128
- mention_obj["annotations"] = MentionElement._default_annotations()
129
- mention_obj["plain_text"] = MentionElement.MENTION_TYPES[mention["type"]][
130
- "get_plain_text"
131
- ](mention_obj)
132
-
133
- rich_text.append(mention_obj)
134
- position = mention["end"]
135
-
136
- # Add remaining text if any
137
- if position < len(text):
138
- rich_text.append(MentionElement._create_text_item(text[position:]))
139
-
140
- return rich_text
141
-
142
- @classmethod
143
- def _create_text_item(cls, content: str) -> Dict[str, Any]:
144
- """Create a text item with default annotations."""
145
- text_item = {
146
- "type": "text",
147
- "text": {"content": content, "link": None},
148
- "annotations": MentionElement._default_annotations(),
149
- "plain_text": content,
150
- }
151
- return text_item
152
-
153
- @classmethod
154
- def _default_annotations(cls) -> Dict[str, Any]:
155
- """Return default annotations for rich text."""
156
- return {
157
- "bold": False,
158
- "italic": False,
159
- "strikethrough": False,
160
- "underline": False,
161
- "code": False,
162
- "color": "default",
163
- }
164
-
165
- @classmethod
166
- def notion_to_markdown(cls, block: Dict[str, Any]) -> Optional[str]:
167
- """Extract mentions from Notion block and convert to markdown format."""
168
- block_type = block.get("type")
169
- if not block_type or block_type not in block:
170
- return None
171
-
172
- block_content = block.get(block_type, {})
173
- rich_text = block_content.get("rich_text", [])
174
-
175
- processed_text = MentionElement._process_rich_text_with_mentions(rich_text)
176
-
177
- if processed_text:
178
- return processed_text
179
-
180
- return None
181
-
182
- @classmethod
183
- def _process_rich_text_with_mentions(cls, rich_text: List[Dict[str, Any]]) -> str:
184
- """Convert rich text with mentions to markdown string."""
185
- result = []
186
-
187
- for item in rich_text:
188
- if item.get("type") == "mention":
189
- mention = item.get("mention", {})
190
- mention_type = mention.get("type")
191
-
192
- if mention_type in MentionElement.MENTION_TYPES:
193
- result.append(
194
- MentionElement.MENTION_TYPES[mention_type]["to_markdown"](item)
195
- )
196
- else:
197
- result.append(item.get("plain_text", "@[unknown]"))
198
- else:
199
- result.append(item.get("plain_text", ""))
200
-
201
- return "".join(result)
202
-
203
- @classmethod
204
- def is_multiline(cls) -> bool:
205
- return False
206
-
207
- @classmethod
208
- def get_llm_prompt_content(cls) -> ElementPromptContent:
209
- """
210
- Returns structured LLM prompt metadata for the mention element.
211
- """
212
- return (
213
- ElementPromptBuilder()
214
- .with_description(
215
- "References to Notion pages, databases, or dates within text content."
216
- )
217
- .with_usage_guidelines(
218
- "When you want to link to other Notion content within your text."
219
- )
220
- .with_syntax("@[page-id]")
221
- .with_examples(
222
- [
223
- "Check the meeting notes at @[1a6389d5-7bd3-80c5-9a87-e90b034989d0]",
224
- "Deadline is @date[2023-12-31]",
225
- "Use the structure in @db[1a6389d5-7bd3-80e9-b199-000cfb3fa0b3]",
226
- ]
227
- )
228
- .build()
229
- )
@@ -1,38 +0,0 @@
1
- from __future__ import annotations
2
- from typing import Literal
3
- from pydantic import BaseModel
4
- from notionary.blocks.markdown_node import MarkdownNode
5
-
6
-
7
- class MentionMarkdownBlockParams(BaseModel):
8
- mention_type: Literal["page", "database", "date"]
9
- value: str
10
-
11
-
12
- class MentionMarkdownNode(MarkdownNode):
13
- """
14
- Programmatic interface for creating Notion-style Markdown mentions.
15
- Supports: page, database, date.
16
- Examples: @[page-id], @db[database-id], @date[YYYY-MM-DD]
17
- """
18
-
19
- def __init__(self, mention_type: str, value: str):
20
- allowed = {"page", "database", "date"}
21
- if mention_type not in allowed:
22
- raise ValueError(f"mention_type must be one of {allowed}")
23
- self.mention_type = mention_type
24
- self.value = value
25
-
26
- @classmethod
27
- def from_params(cls, params: MentionMarkdownBlockParams) -> MentionMarkdownNode:
28
- return cls(mention_type=params.mention_type, value=params.value)
29
-
30
- def to_markdown(self) -> str:
31
- if self.mention_type == "page":
32
- return f"@[{self.value}]"
33
- elif self.mention_type == "database":
34
- return f"@db[{self.value}]"
35
- elif self.mention_type == "date":
36
- return f"@date[{self.value}]"
37
- else:
38
- return f"@[{self.value}]"
@@ -1,83 +0,0 @@
1
- from typing import Optional, List, Self
2
- from notionary.blocks.prompts.element_prompt_content import ElementPromptContent
3
-
4
-
5
- class ElementPromptBuilder:
6
- """
7
- Builder class for creating ElementPromptContent with a fluent interface.
8
- Provides better IDE support and validation for creating prompts.
9
- """
10
-
11
- def __init__(self) -> None:
12
- self._description: Optional[str] = None
13
- self._syntax: Optional[str] = None
14
- self._examples: List[str] = []
15
- self._when_to_use: Optional[str] = None
16
- self._avoid: Optional[str] = None
17
- self._is_standard_markdown = False
18
-
19
- def with_description(self, description: str) -> Self:
20
- """Set the description of the element."""
21
- self._description = description
22
- return self
23
-
24
- def with_syntax(self, syntax: str) -> Self:
25
- """Set the syntax pattern for the element."""
26
- self._syntax = syntax
27
- return self
28
-
29
- def add_example(self, example: str) -> Self:
30
- """Add a usage example for the element."""
31
- self._examples.append(example)
32
- return self
33
-
34
- def with_examples(self, examples: List[str]) -> Self:
35
- """Set the list of usage examples for the element."""
36
- self._examples = examples.copy()
37
- return self
38
-
39
- def with_usage_guidelines(self, when_to_use: str) -> Self:
40
- """Set the usage guidelines for the element."""
41
- self._when_to_use = when_to_use
42
- return self
43
-
44
- def with_avoidance_guidelines(self, avoid: str) -> Self:
45
- """Set the scenarios when this element should be avoided."""
46
- self._avoid = avoid
47
- return self
48
-
49
- def with_standard_markdown(self) -> Self:
50
- """Indicate that this element follows standard Markdown syntax."""
51
- self._examples = []
52
- self._is_standard_markdown = True
53
- return self
54
-
55
- def build(self) -> ElementPromptContent:
56
- """
57
- Build and validate the ElementPromptContent object.
58
-
59
- Returns:
60
- A valid ElementPromptContent object.
61
-
62
- Raises:
63
- ValueError: If any required field is missing.
64
- """
65
- if not self._description:
66
- raise ValueError("Description is required")
67
- if not self._syntax:
68
- raise ValueError("Syntax is required")
69
- if not self._examples and not self._is_standard_markdown:
70
- raise ValueError(
71
- "At least one example is required unless it's standard markdown."
72
- )
73
- if not self._when_to_use:
74
- raise ValueError("Usage guidelines are required")
75
-
76
- return ElementPromptContent(
77
- description=self._description,
78
- syntax=self._syntax,
79
- examples=self._examples,
80
- when_to_use=self._when_to_use,
81
- avoid=self._avoid,
82
- is_standard_markdown=self._is_standard_markdown,
83
- )
@@ -1,41 +0,0 @@
1
- from dataclasses import field, dataclass
2
- from typing import Optional, List
3
-
4
-
5
- @dataclass
6
- class ElementPromptContent:
7
- """
8
- Dataclass defining the standardized structure for element prompt content.
9
- This ensures consistent formatting across all Notion block elements.
10
- """
11
-
12
- description: str
13
- """Concise explanation of what the element is and its purpose in Notion."""
14
-
15
- syntax: str
16
- """The exact markdown syntax pattern used to create this element."""
17
-
18
- when_to_use: str
19
- """Guidelines explaining the appropriate scenarios for using this element."""
20
-
21
- examples: List[str] = field(default_factory=list)
22
- """List of practical usage examples showing the element in context."""
23
-
24
- avoid: Optional[str] = None
25
- """Optional field listing scenarios when this element should be avoided."""
26
-
27
- is_standard_markdown: bool = False
28
- """Indicates whether this element follows standard Markdown syntax (and does not require full examples)."""
29
-
30
- def __post_init__(self):
31
- """Validates that the content meets minimum requirements."""
32
- if not self.description:
33
- raise ValueError("Description is required")
34
- if not self.syntax:
35
- raise ValueError("Syntax is required")
36
- if not self.examples and not self.is_standard_markdown:
37
- raise ValueError(
38
- "At least one example is required unless it's standard markdown."
39
- )
40
- if not self.when_to_use:
41
- raise ValueError("Usage guidelines are required")
File without changes