notionary 0.2.2__tar.gz → 0.2.4__tar.gz

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 (66) hide show
  1. {notionary-0.2.2 → notionary-0.2.4}/PKG-INFO +1 -1
  2. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/registry/block_registry_builder.py +1 -1
  3. {notionary-0.2.2 → notionary-0.2.4}/notionary/models/notion_database_response.py +1 -2
  4. {notionary-0.2.2 → notionary-0.2.4}/notionary/notion_client.py +0 -2
  5. notionary-0.2.4/notionary/prompting/markdown_syntax_prompt_generator.py +111 -0
  6. {notionary-0.2.2 → notionary-0.2.4}/notionary.egg-info/PKG-INFO +1 -1
  7. {notionary-0.2.2 → notionary-0.2.4}/setup.py +1 -1
  8. notionary-0.2.2/notionary/prompting/markdown_syntax_prompt_generator.py +0 -92
  9. {notionary-0.2.2 → notionary-0.2.4}/LICENSE +0 -0
  10. {notionary-0.2.2 → notionary-0.2.4}/README.md +0 -0
  11. {notionary-0.2.2 → notionary-0.2.4}/notionary/__init__.py +0 -0
  12. {notionary-0.2.2 → notionary-0.2.4}/notionary/database/database_discovery.py +0 -0
  13. {notionary-0.2.2 → notionary-0.2.4}/notionary/database/models/page_result.py +0 -0
  14. {notionary-0.2.2 → notionary-0.2.4}/notionary/database/notion_database.py +0 -0
  15. {notionary-0.2.2 → notionary-0.2.4}/notionary/database/notion_database_factory.py +0 -0
  16. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/audio_element.py +0 -0
  17. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/bookmark_element.py +0 -0
  18. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/bulleted_list_element.py +0 -0
  19. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/callout_element.py +0 -0
  20. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/code_block_element.py +0 -0
  21. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/divider_element.py +0 -0
  22. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/embed_element.py +0 -0
  23. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/heading_element.py +0 -0
  24. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/image_element.py +0 -0
  25. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/mention_element.py +0 -0
  26. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/notion_block_element.py +0 -0
  27. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/numbered_list_element.py +0 -0
  28. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/paragraph_element.py +0 -0
  29. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/qoute_element.py +0 -0
  30. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/registry/block_registry.py +0 -0
  31. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/table_element.py +0 -0
  32. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/text_inline_formatter.py +0 -0
  33. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/todo_element.py +0 -0
  34. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/toggle_element.py +0 -0
  35. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/toggleable_heading_element.py +0 -0
  36. {notionary-0.2.2 → notionary-0.2.4}/notionary/elements/video_element.py +0 -0
  37. {notionary-0.2.2 → notionary-0.2.4}/notionary/exceptions/database_exceptions.py +0 -0
  38. {notionary-0.2.2 → notionary-0.2.4}/notionary/exceptions/page_creation_exception.py +0 -0
  39. {notionary-0.2.2 → notionary-0.2.4}/notionary/models/notion_block_response.py +0 -0
  40. {notionary-0.2.2 → notionary-0.2.4}/notionary/models/notion_page_response.py +0 -0
  41. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/content/notion_page_content_chunker.py +0 -0
  42. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/content/page_content_retriever.py +0 -0
  43. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/content/page_content_writer.py +0 -0
  44. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/markdown_to_notion_converter.py +0 -0
  45. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/metadata/metadata_editor.py +0 -0
  46. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/metadata/notion_icon_manager.py +0 -0
  47. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/metadata/notion_page_cover_manager.py +0 -0
  48. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/notion_page.py +0 -0
  49. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/notion_page_factory.py +0 -0
  50. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/notion_to_markdown_converter.py +0 -0
  51. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/properites/database_property_service.py +0 -0
  52. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/properites/page_property_manager.py +0 -0
  53. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/properites/property_formatter.py +0 -0
  54. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/properites/property_value_extractor.py +0 -0
  55. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/relations/notion_page_relation_manager.py +0 -0
  56. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/relations/notion_page_title_resolver.py +0 -0
  57. {notionary-0.2.2 → notionary-0.2.4}/notionary/page/relations/page_database_relation.py +0 -0
  58. {notionary-0.2.2 → notionary-0.2.4}/notionary/prompting/element_prompt_content.py +0 -0
  59. {notionary-0.2.2 → notionary-0.2.4}/notionary/util/logging_mixin.py +0 -0
  60. {notionary-0.2.2 → notionary-0.2.4}/notionary/util/page_id_utils.py +0 -0
  61. {notionary-0.2.2 → notionary-0.2.4}/notionary/util/warn_direct_constructor_usage.py +0 -0
  62. {notionary-0.2.2 → notionary-0.2.4}/notionary.egg-info/SOURCES.txt +0 -0
  63. {notionary-0.2.2 → notionary-0.2.4}/notionary.egg-info/dependency_links.txt +0 -0
  64. {notionary-0.2.2 → notionary-0.2.4}/notionary.egg-info/requires.txt +0 -0
  65. {notionary-0.2.2 → notionary-0.2.4}/notionary.egg-info/top_level.txt +0 -0
  66. {notionary-0.2.2 → notionary-0.2.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: A toolkit to convert between Markdown and Notion blocks
5
5
  Home-page: https://github.com/mathisarends/notionary
6
6
  Author: Mathis Arends
@@ -67,7 +67,7 @@ class BlockRegistryBuilder:
67
67
  .with_paragraphs()
68
68
  .with_toggleable_heading_element()
69
69
  ).build()
70
-
70
+
71
71
  @classmethod
72
72
  def create_minimal_registry(cls) -> BlockRegistry:
73
73
  """
@@ -1,4 +1,3 @@
1
-
2
1
  from pydantic import BaseModel
3
2
  from dataclasses import dataclass
4
3
  from typing import Optional, List, Dict, Any, Literal
@@ -55,4 +54,4 @@ class NotionDatabaseResponse(BaseModel):
55
54
  public_url: Optional[str]
56
55
  archived: bool
57
56
  in_trash: bool
58
- request_id: Optional[str] = None
57
+ request_id: Optional[str] = None
@@ -69,8 +69,6 @@ class NotionClient(LoggingMixin):
69
69
  """
70
70
  return await self._make_request(HttpMethod.GET, endpoint)
71
71
 
72
- # TODO: Get Blocks implementeren und Patch Blcoks hierfür das Typing finden:
73
-
74
72
  async def get_database(self, database_id: str) -> NotionDatabaseResponse:
75
73
  """
76
74
  Ruft die Metadaten einer Notion-Datenbank anhand ihrer ID ab und gibt sie als NotionPageResponse zurück.
@@ -0,0 +1,111 @@
1
+ from textwrap import dedent
2
+ from typing import Type, List
3
+ from notionary.elements.notion_block_element import NotionBlockElement
4
+
5
+
6
+ class MarkdownSyntaxPromptGenerator:
7
+ """
8
+ Generator for LLM system prompts that describe Notion-Markdown syntax.
9
+
10
+ This class extracts information about supported Markdown patterns
11
+ and formats them optimally for LLMs.
12
+ """
13
+
14
+ SYSTEM_PROMPT_TEMPLATE = dedent(
15
+ """
16
+ You are a knowledgeable assistant that helps users create content for Notion pages.
17
+ Notion supports standard Markdown with some special extensions for creating rich content.
18
+
19
+ # Understanding Notion Blocks
20
+
21
+ Notion documents are composed of individual blocks. Each block has a specific type (paragraph, heading, list item, etc.) and format.
22
+ The Markdown syntax you use directly maps to these Notion blocks.
23
+
24
+ {element_docs}
25
+
26
+ CRITICAL USAGE GUIDELINES:
27
+
28
+ 1. Do NOT start content with a level 1 heading (# Heading). In Notion, the page title is already displayed in the metadata, so starting with an H1 heading is redundant. Begin with H2 (## Heading) or lower for section headings.
29
+
30
+ 2. INLINE FORMATTING - VERY IMPORTANT:
31
+ ✅ You can use inline formatting within almost any block type.
32
+ ✅ Combine **bold**, _italic_, `code`, and other formatting as needed.
33
+ ✅ Format text to create visual hierarchy and emphasize important points.
34
+ ❌ DO NOT overuse formatting - be strategic with formatting for best readability.
35
+
36
+ 3. BACKTICK HANDLING - EXTREMELY IMPORTANT:
37
+ ❌ NEVER wrap entire content or responses in triple backticks (```).
38
+ ❌ DO NOT use triple backticks (```) for anything except CODE BLOCKS or DIAGRAMS.
39
+ ❌ DO NOT use triple backticks to mark or highlight regular text or examples.
40
+ ✅ USE triple backticks ONLY for actual programming code, pseudocode, or specialized notation.
41
+ ✅ For inline code, use single backticks (`code`).
42
+ ✅ When showing Markdown syntax examples, use inline code formatting with single backticks.
43
+
44
+ 4. BLOCK SEPARATION - IMPORTANT:
45
+ ✅ Use empty lines between different blocks to ensure proper rendering in Notion.
46
+ ✅ For major logical sections, use the spacer element (see documentation below).
47
+ ⚠️ While headings can sometimes work without an empty line before the following paragraph, including empty lines between all block types ensures consistent rendering.
48
+
49
+ 5. CONTENT FORMATTING - CRITICAL:
50
+ ❌ DO NOT include introductory phrases like "I understand that..." or "Here's the content...".
51
+ ✅ Provide ONLY the requested content directly without any prefacing text or meta-commentary.
52
+ ✅ Generate just the content itself, formatted according to these guidelines."""
53
+ )
54
+
55
+ @staticmethod
56
+ def generate_element_doc(element_class: Type[NotionBlockElement]) -> str:
57
+ """
58
+ Generates documentation for a specific NotionBlockElement in a compact format.
59
+ Uses the element's get_llm_prompt_content method if available.
60
+ """
61
+ class_name = element_class.__name__
62
+ element_name = class_name.replace("Element", "")
63
+
64
+ content = element_class.get_llm_prompt_content()
65
+
66
+ doc_parts = [
67
+ f"## {element_name}",
68
+ f"{content.description}",
69
+ f"**Syntax:** {content.syntax}",
70
+ ]
71
+
72
+ if content.examples:
73
+ doc_parts.append("**Examples:**")
74
+ for example in content.examples:
75
+ doc_parts.append(example)
76
+
77
+ doc_parts.append(f"**When to use:** {content.when_to_use}")
78
+
79
+ if content.avoid:
80
+ doc_parts.append(f"**Avoid:** {content.avoid}")
81
+
82
+ return "\n".join([part for part in doc_parts if part])
83
+
84
+ @classmethod
85
+ def generate_element_docs(
86
+ cls, element_classes: List[Type[NotionBlockElement]]
87
+ ) -> str:
88
+ """
89
+ Generates complete documentation for all provided element classes.
90
+ """
91
+ docs = [
92
+ "# Markdown Syntax for Notion Blocks",
93
+ "The following Markdown patterns are supported for creating Notion blocks:",
94
+ ]
95
+
96
+ # Generate docs for each element
97
+ for element in element_classes:
98
+ docs.append("\n" + cls.generate_element_doc(element))
99
+
100
+ return "\n".join(docs)
101
+
102
+ @classmethod
103
+ def generate_system_prompt(
104
+ cls,
105
+ element_classes: List[Type[NotionBlockElement]],
106
+ ) -> str:
107
+ """
108
+ Generates a complete system prompt for LLMs.
109
+ """
110
+ element_docs = cls.generate_element_docs(element_classes)
111
+ return cls.SYSTEM_PROMPT_TEMPLATE.format(element_docs=element_docs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: A toolkit to convert between Markdown and Notion blocks
5
5
  Home-page: https://github.com/mathisarends/notionary
6
6
  Author: Mathis Arends
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name="notionary",
5
- version="0.2.2",
5
+ version="0.2.4",
6
6
  packages=find_namespace_packages(include=["notionary*"]),
7
7
  install_requires=["httpx>=0.28.0", "python-dotenv>=1.1.0", "pydantic>=2.11.4"],
8
8
  author="Mathis Arends",
@@ -1,92 +0,0 @@
1
- import os
2
- from pathlib import Path
3
- from typing import Type, List
4
- from notionary.elements.notion_block_element import NotionBlockElement
5
-
6
-
7
- class MarkdownSyntaxPromptGenerator:
8
- """
9
- Generator for LLM system prompts that describe Notion-Markdown syntax.
10
-
11
- This class extracts information about supported Markdown patterns
12
- and formats them optimally for LLMs.
13
- """
14
-
15
- def __init__(self):
16
- # Lade das Template aus der Markdown-Datei
17
- self.SYSTEM_PROMPT_TEMPLATE = self._load_template()
18
-
19
- def _load_template(self) -> str:
20
- """
21
- Lädt das Prompt-Template aus der Markdown-Datei.
22
- """
23
- current_dir = Path(__file__).parent
24
- template_path = current_dir / "res/notion_syntax_prompt.md"
25
-
26
- try:
27
- with open(template_path, "r", encoding="utf-8") as file:
28
- return file.read()
29
- except FileNotFoundError:
30
- raise FileNotFoundError(f"Template file not found at {template_path}")
31
- except Exception as e:
32
- raise RuntimeError(f"Error loading template file: {e}")
33
-
34
- @staticmethod
35
- def generate_element_doc(element_class: Type[NotionBlockElement]) -> str:
36
- """
37
- Generates documentation for a specific NotionBlockElement in a compact format.
38
- Uses the element's get_llm_prompt_content method if available.
39
- """
40
- class_name = element_class.__name__
41
- element_name = class_name.replace("Element", "")
42
-
43
- content = element_class.get_llm_prompt_content()
44
-
45
- doc_parts = [
46
- f"## {element_name}",
47
- f"{content.description}",
48
- f"**Syntax:** {content.syntax}",
49
- ]
50
-
51
- if content.examples:
52
- doc_parts.append("**Examples:**")
53
- for example in content.examples:
54
- doc_parts.append(example)
55
-
56
- doc_parts.append(f"**When to use:** {content.when_to_use}")
57
-
58
- if content.avoid:
59
- doc_parts.append(f"**Avoid:** {content.avoid}")
60
-
61
- return "\n".join([part for part in doc_parts if part])
62
-
63
- @classmethod
64
- def generate_element_docs(
65
- cls, element_classes: List[Type[NotionBlockElement]]
66
- ) -> str:
67
- """
68
- Generates complete documentation for all provided element classes.
69
- """
70
- docs = [
71
- "# Markdown Syntax for Notion Blocks",
72
- "The following Markdown patterns are supported for creating Notion blocks:",
73
- ]
74
-
75
- # Generate docs for each element
76
- for element in element_classes:
77
- docs.append("\n" + cls.generate_element_doc(element))
78
-
79
- return "\n".join(docs)
80
-
81
- @classmethod
82
- def generate_system_prompt(
83
- cls,
84
- element_classes: List[Type[NotionBlockElement]],
85
- ) -> str:
86
- """
87
- Generates a complete system prompt for LLMs.
88
- """
89
- # Erstelle eine Instanz, um das Template zu laden
90
- instance = cls()
91
- element_docs = cls.generate_element_docs(element_classes)
92
- return instance.SYSTEM_PROMPT_TEMPLATE.format(element_docs=element_docs)
File without changes
File without changes
File without changes