Skip to content

Commit c363946

Browse files
committed
feat: Implement layout algorithms and validation for diagrams
- Added ForceDirectedLayout and HierarchicalLayout classes for diagram positioning. - Introduced LayoutEngine to manage layout algorithms. - Created a PluginManager for extensibility with plugin registration and execution. - Developed DiagramValidator for validating diagram structure and rules. - Implemented DiagramLinter for style and best practices linting. - Added ViewerServer for interactive web viewing of diagrams. - Updated pyproject.toml to include new dependencies and version bump to 0.1.4.
1 parent 8bf1713 commit c363946

25 files changed

Lines changed: 4802 additions & 3 deletions

examples/comprehensive_features.py

Lines changed: 441 additions & 0 deletions
Large diffs are not rendered by default.

ij/__init__.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
natural language, visual diagrams, and code.
55
"""
66

7+
# Core
78
from .analyzers import PythonCodeAnalyzer
89
from .core import DiagramIR, Edge, EdgeType, Node, NodeType
910
from .converters import EnhancedTextConverter, SimpleTextConverter
@@ -19,16 +20,40 @@
1920
SequenceDiagramRenderer,
2021
)
2122

23+
# New modules
24+
from .validation import DiagramValidator, DiagramLinter, ValidationResult
25+
from .git_integration import DiagramDiff, DiagramHistory
26+
from .diagrams import ERDiagram, Entity, Field, Cardinality, StateMachine, State
27+
from .export import ImageExporter, quick_export
28+
from .layout import LayoutEngine, ForceDirectedLayout, HierarchicalLayout
29+
from .plugins import PluginManager, register_plugin, register_transform
30+
from .viewer import ViewerServer, serve_diagram
31+
32+
# Optional analyzers
33+
try:
34+
from .analyzers.typescript import TypeScriptAnalyzer, analyze_package_json
35+
_has_typescript = True
36+
except ImportError:
37+
_has_typescript = False
38+
39+
# Optional importers
40+
try:
41+
from . import importers
42+
_has_importers = True
43+
except ImportError:
44+
_has_importers = False
45+
2246
# LLMConverter is optional (requires openai package)
2347
try:
2448
from .converters import LLMConverter
2549
_has_llm = True
2650
except ImportError:
2751
_has_llm = False
2852

29-
__version__ = "0.1.1"
53+
__version__ = "0.2.0"
3054

3155
__all__ = [
56+
# Core
3257
"DiagramIR",
3358
"Node",
3459
"Edge",
@@ -47,11 +72,47 @@
4772
"GraphOperations",
4873
"PythonCodeAnalyzer",
4974
"DiagramTransforms",
75+
# Validation
76+
"DiagramValidator",
77+
"DiagramLinter",
78+
"ValidationResult",
79+
# Git integration
80+
"DiagramDiff",
81+
"DiagramHistory",
82+
# Diagrams
83+
"ERDiagram",
84+
"Entity",
85+
"Field",
86+
"Cardinality",
87+
"StateMachine",
88+
"State",
89+
# Export
90+
"ImageExporter",
91+
"quick_export",
92+
# Layout
93+
"LayoutEngine",
94+
"ForceDirectedLayout",
95+
"HierarchicalLayout",
96+
# Plugins
97+
"PluginManager",
98+
"register_plugin",
99+
"register_transform",
100+
# Viewer
101+
"ViewerServer",
102+
"serve_diagram",
103+
# Convenience
104+
"text_to_mermaid",
50105
]
51106

52107
if _has_llm:
53108
__all__.append("LLMConverter")
54109

110+
if _has_typescript:
111+
__all__.extend(["TypeScriptAnalyzer", "analyze_package_json"])
112+
113+
if _has_importers:
114+
__all__.append("importers")
115+
55116

56117
def text_to_mermaid(text: str, title: str = None, direction: str = "TD") -> str:
57118
"""Convert text description to Mermaid diagram (convenience function).

0 commit comments

Comments
 (0)