Support for plantuml diagrams

This commit is contained in:
Yiorgis Gozadinos 2026-03-13 17:18:19 +02:00
parent f961f00f2c
commit d4e34ab79f
No known key found for this signature in database
4 changed files with 31 additions and 0 deletions

View file

@ -1,6 +1,10 @@
# Changelog # Changelog
## [Unreleased] ## [Unreleased]
### Added
- **PlantUML support**: `.puml`, `.plantuml`, and `.pu` files are now indexed as `plantuml` code blocks
## [0.34.0] - 2026-03-13 ## [0.34.0] - 2026-03-13
### Added ### Added

View file

@ -109,6 +109,7 @@ The file monitor processes documents using [Docling](https://github.com/DS4SD/do
- Python (`.py`) - Python (`.py`)
- JavaScript (`.js`) - JavaScript (`.js`)
- TypeScript (`.ts`) - TypeScript (`.ts`)
- PlantUML (`.puml`, `.plantuml`, `.pu`)
- And other text-based code files - And other text-based code files
**Plain text:** **Plain text:**

View file

@ -54,8 +54,11 @@ class TextFileHandler:
".nix", ".nix",
".php", ".php",
".pl", ".pl",
".plantuml",
".pm", ".pm",
".proto", ".proto",
".pu",
".puml",
".ps1", ".ps1",
".py", ".py",
".r", ".r",
@ -118,8 +121,11 @@ class TextFileHandler:
".nix": "nix", ".nix": "nix",
".php": "php", ".php": "php",
".pl": "perl", ".pl": "perl",
".plantuml": "plantuml",
".pm": "perl", ".pm": "perl",
".proto": "protobuf", ".proto": "protobuf",
".pu": "plantuml",
".puml": "plantuml",
".ps1": "powershell", ".ps1": "powershell",
".py": "python", ".py": "python",
".r": "r", ".r": "r",

View file

@ -89,12 +89,24 @@ class TestTextFileHandler:
assert ".js" in TextFileHandler.text_extensions assert ".js" in TextFileHandler.text_extensions
assert ".txt" 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): def test_code_markdown_identifiers(self):
"""Test code language identifiers mapping.""" """Test code language identifiers mapping."""
assert TextFileHandler.code_markdown_identifier[".py"] == "python" assert TextFileHandler.code_markdown_identifier[".py"] == "python"
assert TextFileHandler.code_markdown_identifier[".js"] == "javascript" assert TextFileHandler.code_markdown_identifier[".js"] == "javascript"
assert TextFileHandler.code_markdown_identifier[".ts"] == "typescript" 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): def test_prepare_text_content_with_code(self):
"""Test that code files are wrapped in markdown code blocks.""" """Test that code files are wrapped in markdown code blocks."""
code = "def hello():\n pass" code = "def hello():\n pass"
@ -103,6 +115,14 @@ class TestTextFileHandler:
assert result.endswith("\n```") assert result.endswith("\n```")
assert "def hello():" in result 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): def test_prepare_text_content_without_code(self):
"""Test that plain text files are not wrapped.""" """Test that plain text files are not wrapped."""
text = "Hello world" text = "Hello world"