diff --git a/CHANGELOG.md b/CHANGELOG.md index 07293805..8182b0a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Added + +- **PlantUML support**: `.puml`, `.plantuml`, and `.pu` files are now indexed as `plantuml` code blocks + ## [0.34.0] - 2026-03-13 ### Added diff --git a/docs/server.md b/docs/server.md index 3f6ba3ef..40bd46b4 100644 --- a/docs/server.md +++ b/docs/server.md @@ -109,6 +109,7 @@ The file monitor processes documents using [Docling](https://github.com/DS4SD/do - Python (`.py`) - JavaScript (`.js`) - TypeScript (`.ts`) +- PlantUML (`.puml`, `.plantuml`, `.pu`) - And other text-based code files **Plain text:** diff --git a/haiku_rag_slim/haiku/rag/converters/text_utils.py b/haiku_rag_slim/haiku/rag/converters/text_utils.py index eb521b50..270ddf1f 100644 --- a/haiku_rag_slim/haiku/rag/converters/text_utils.py +++ b/haiku_rag_slim/haiku/rag/converters/text_utils.py @@ -54,8 +54,11 @@ class TextFileHandler: ".nix", ".php", ".pl", + ".plantuml", ".pm", ".proto", + ".pu", + ".puml", ".ps1", ".py", ".r", @@ -118,8 +121,11 @@ class TextFileHandler: ".nix": "nix", ".php": "php", ".pl": "perl", + ".plantuml": "plantuml", ".pm": "perl", ".proto": "protobuf", + ".pu": "plantuml", + ".puml": "plantuml", ".ps1": "powershell", ".py": "python", ".r": "r", diff --git a/tests/test_converters.py b/tests/test_converters.py index 7775cf09..c5a8435c 100644 --- a/tests/test_converters.py +++ b/tests/test_converters.py @@ -89,12 +89,24 @@ class TestTextFileHandler: assert ".js" in TextFileHandler.text_extensions assert ".txt" in TextFileHandler.text_extensions + def test_plantuml_extensions_supported(self): + """Test that PlantUML extensions are in text_extensions.""" + assert ".puml" in TextFileHandler.text_extensions + assert ".plantuml" in TextFileHandler.text_extensions + assert ".pu" in TextFileHandler.text_extensions + def test_code_markdown_identifiers(self): """Test code language identifiers mapping.""" assert TextFileHandler.code_markdown_identifier[".py"] == "python" assert TextFileHandler.code_markdown_identifier[".js"] == "javascript" assert TextFileHandler.code_markdown_identifier[".ts"] == "typescript" + def test_plantuml_markdown_identifiers(self): + """Test PlantUML language identifiers mapping.""" + assert TextFileHandler.code_markdown_identifier[".puml"] == "plantuml" + assert TextFileHandler.code_markdown_identifier[".plantuml"] == "plantuml" + assert TextFileHandler.code_markdown_identifier[".pu"] == "plantuml" + def test_prepare_text_content_with_code(self): """Test that code files are wrapped in markdown code blocks.""" code = "def hello():\n pass" @@ -103,6 +115,14 @@ class TestTextFileHandler: assert result.endswith("\n```") assert "def hello():" in result + def test_prepare_text_content_with_plantuml(self): + """Test that PlantUML files are wrapped in plantuml code blocks.""" + puml = "@startuml\nAlice -> Bob: Hello\n@enduml" + result = TextFileHandler.prepare_text_content(puml, ".puml") + assert result.startswith("```plantuml\n") + assert result.endswith("\n```") + assert "@startuml" in result + def test_prepare_text_content_without_code(self): """Test that plain text files are not wrapped.""" text = "Hello world"