Spaces:
Running
Running
Update class_diagram_generator.py
Browse files- class_diagram_generator.py +0 -357
class_diagram_generator.py
CHANGED
|
@@ -1,360 +1,3 @@
|
|
| 1 |
-
# import graphviz
|
| 2 |
-
# import json
|
| 3 |
-
# from tempfile import NamedTemporaryFile
|
| 4 |
-
# import os
|
| 5 |
-
|
| 6 |
-
# def generate_class_diagram(json_input: str, output_format: str) -> str:
|
| 7 |
-
# """
|
| 8 |
-
# Generates a class diagram from JSON input.
|
| 9 |
-
|
| 10 |
-
# Args:
|
| 11 |
-
# json_input (str): A JSON string describing the class diagram structure.
|
| 12 |
-
# It must follow the Expected JSON Format Example below.
|
| 13 |
-
|
| 14 |
-
# Expected JSON Format Example:
|
| 15 |
-
# {
|
| 16 |
-
# "classes": [
|
| 17 |
-
# {
|
| 18 |
-
# "name": "Vehicle",
|
| 19 |
-
# "type": "abstract",
|
| 20 |
-
# "attributes": [
|
| 21 |
-
# {"name": "id", "type": "String", "visibility": "-"},
|
| 22 |
-
# {"name": "brand", "type": "String", "visibility": "#"},
|
| 23 |
-
# {"name": "model", "type": "String", "visibility": "#"},
|
| 24 |
-
# {"name": "year", "type": "int", "visibility": "#"},
|
| 25 |
-
# {"name": "price", "type": "double", "visibility": "+"},
|
| 26 |
-
# {"name": "vehicleCount", "type": "int", "visibility": "+", "static": true}
|
| 27 |
-
# ],
|
| 28 |
-
# "methods": [
|
| 29 |
-
# {"name": "Vehicle", "parameters": [{"name": "brand", "type": "String"}, {"name": "model", "type": "String"}], "return_type": "Vehicle", "visibility": "+"},
|
| 30 |
-
# {"name": "startEngine", "return_type": "void", "visibility": "+", "abstract": true},
|
| 31 |
-
# {"name": "stopEngine", "return_type": "void", "visibility": "+"},
|
| 32 |
-
# {"name": "getPrice", "return_type": "double", "visibility": "+"},
|
| 33 |
-
# {"name": "setPrice", "parameters": [{"name": "price", "type": "double"}], "return_type": "void", "visibility": "+"},
|
| 34 |
-
# {"name": "getTotalVehicles", "return_type": "int", "visibility": "+", "static": true}
|
| 35 |
-
# ]
|
| 36 |
-
# },
|
| 37 |
-
# {
|
| 38 |
-
# "name": "Car",
|
| 39 |
-
# "type": "class",
|
| 40 |
-
# "attributes": [
|
| 41 |
-
# {"name": "doors", "type": "int", "visibility": "-"},
|
| 42 |
-
# {"name": "transmission", "type": "TransmissionType", "visibility": "-"},
|
| 43 |
-
# {"name": "fuelType", "type": "FuelType", "visibility": "-"}
|
| 44 |
-
# ],
|
| 45 |
-
# "methods": [
|
| 46 |
-
# {"name": "Car", "parameters": [{"name": "brand", "type": "String"}, {"name": "model", "type": "String"}, {"name": "doors", "type": "int"}], "return_type": "Car", "visibility": "+"},
|
| 47 |
-
# {"name": "startEngine", "return_type": "void", "visibility": "+"},
|
| 48 |
-
# {"name": "openTrunk", "return_type": "void", "visibility": "+"},
|
| 49 |
-
# {"name": "getDoors", "return_type": "int", "visibility": "+"},
|
| 50 |
-
# {"name": "setTransmission", "parameters": [{"name": "transmission", "type": "TransmissionType"}], "return_type": "void", "visibility": "+"}
|
| 51 |
-
# ]
|
| 52 |
-
# },
|
| 53 |
-
# {
|
| 54 |
-
# "name": "Motorcycle",
|
| 55 |
-
# "type": "class",
|
| 56 |
-
# "attributes": [
|
| 57 |
-
# {"name": "engineSize", "type": "int", "visibility": "-"},
|
| 58 |
-
# {"name": "hasWindshield", "type": "boolean", "visibility": "-"}
|
| 59 |
-
# ],
|
| 60 |
-
# "methods": [
|
| 61 |
-
# {"name": "Motorcycle", "parameters": [{"name": "brand", "type": "String"}, {"name": "model", "type": "String"}], "return_type": "Motorcycle", "visibility": "+"},
|
| 62 |
-
# {"name": "startEngine", "return_type": "void", "visibility": "+"},
|
| 63 |
-
# {"name": "wheelie", "return_type": "void", "visibility": "+"},
|
| 64 |
-
# {"name": "getEngineSize", "return_type": "int", "visibility": "+"}
|
| 65 |
-
# ]
|
| 66 |
-
# },
|
| 67 |
-
# {
|
| 68 |
-
# "name": "Engine",
|
| 69 |
-
# "type": "class",
|
| 70 |
-
# "attributes": [
|
| 71 |
-
# {"name": "horsepower", "type": "int", "visibility": "-"},
|
| 72 |
-
# {"name": "cylinders", "type": "int", "visibility": "-"},
|
| 73 |
-
# {"name": "fuelType", "type": "FuelType", "visibility": "-"}
|
| 74 |
-
# ],
|
| 75 |
-
# "methods": [
|
| 76 |
-
# {"name": "Engine", "parameters": [{"name": "horsepower", "type": "int"}, {"name": "cylinders", "type": "int"}], "return_type": "Engine", "visibility": "+"},
|
| 77 |
-
# {"name": "start", "return_type": "boolean", "visibility": "+"},
|
| 78 |
-
# {"name": "stop", "return_type": "void", "visibility": "+"},
|
| 79 |
-
# {"name": "getHorsepower", "return_type": "int", "visibility": "+"}
|
| 80 |
-
# ]
|
| 81 |
-
# },
|
| 82 |
-
# {
|
| 83 |
-
# "name": "TransmissionType",
|
| 84 |
-
# "type": "enum",
|
| 85 |
-
# "attributes": [
|
| 86 |
-
# {"name": "MANUAL", "type": "TransmissionType", "visibility": "+", "static": true},
|
| 87 |
-
# {"name": "AUTOMATIC", "type": "TransmissionType", "visibility": "+", "static": true},
|
| 88 |
-
# {"name": "CVT", "type": "TransmissionType", "visibility": "+", "static": true}
|
| 89 |
-
# ],
|
| 90 |
-
# "methods": []
|
| 91 |
-
# },
|
| 92 |
-
# {
|
| 93 |
-
# "name": "FuelType",
|
| 94 |
-
# "type": "enum",
|
| 95 |
-
# "attributes": [
|
| 96 |
-
# {"name": "GASOLINE", "type": "FuelType", "visibility": "+", "static": true},
|
| 97 |
-
# {"name": "DIESEL", "type": "FuelType", "visibility": "+", "static": true},
|
| 98 |
-
# {"name": "ELECTRIC", "type": "FuelType", "visibility": "+", "static": true},
|
| 99 |
-
# {"name": "HYBRID", "type": "FuelType", "visibility": "+", "static": true}
|
| 100 |
-
# ],
|
| 101 |
-
# "methods": []
|
| 102 |
-
# },
|
| 103 |
-
# {
|
| 104 |
-
# "name": "VehicleService",
|
| 105 |
-
# "type": "interface",
|
| 106 |
-
# "attributes": [],
|
| 107 |
-
# "methods": [
|
| 108 |
-
# {"name": "maintenance", "parameters": [{"name": "vehicle", "type": "Vehicle"}], "return_type": "void", "visibility": "+", "abstract": true},
|
| 109 |
-
# {"name": "repair", "parameters": [{"name": "vehicle", "type": "Vehicle"}, {"name": "issue", "type": "String"}], "return_type": "boolean", "visibility": "+", "abstract": true},
|
| 110 |
-
# {"name": "inspectVehicle", "parameters": [{"name": "vehicle", "type": "Vehicle"}], "return_type": "InspectionReport", "visibility": "+", "abstract": true}
|
| 111 |
-
# ]
|
| 112 |
-
# },
|
| 113 |
-
# {
|
| 114 |
-
# "name": "GarageService",
|
| 115 |
-
# "type": "class",
|
| 116 |
-
# "attributes": [
|
| 117 |
-
# {"name": "garageName", "type": "String", "visibility": "-"},
|
| 118 |
-
# {"name": "location", "type": "String", "visibility": "-"}
|
| 119 |
-
# ],
|
| 120 |
-
# "methods": [
|
| 121 |
-
# {"name": "GarageService", "parameters": [{"name": "name", "type": "String"}], "return_type": "GarageService", "visibility": "+"},
|
| 122 |
-
# {"name": "maintenance", "parameters": [{"name": "vehicle", "type": "Vehicle"}], "return_type": "void", "visibility": "+"},
|
| 123 |
-
# {"name": "repair", "parameters": [{"name": "vehicle", "type": "Vehicle"}, {"name": "issue", "type": "String"}], "return_type": "boolean", "visibility": "+"},
|
| 124 |
-
# {"name": "inspectVehicle", "parameters": [{"name": "vehicle", "type": "Vehicle"}], "return_type": "InspectionReport", "visibility": "+"}
|
| 125 |
-
# ]
|
| 126 |
-
# }
|
| 127 |
-
# ],
|
| 128 |
-
# "relationships": [
|
| 129 |
-
# {
|
| 130 |
-
# "from": "Car",
|
| 131 |
-
# "to": "Vehicle",
|
| 132 |
-
# "type": "inheritance",
|
| 133 |
-
# "label": "extends"
|
| 134 |
-
# },
|
| 135 |
-
# {
|
| 136 |
-
# "from": "Motorcycle",
|
| 137 |
-
# "to": "Vehicle",
|
| 138 |
-
# "type": "inheritance",
|
| 139 |
-
# "label": "extends"
|
| 140 |
-
# },
|
| 141 |
-
# {
|
| 142 |
-
# "from": "Car",
|
| 143 |
-
# "to": "Engine",
|
| 144 |
-
# "type": "composition",
|
| 145 |
-
# "label": "has",
|
| 146 |
-
# "multiplicity_from": "1",
|
| 147 |
-
# "multiplicity_to": "1"
|
| 148 |
-
# },
|
| 149 |
-
# {
|
| 150 |
-
# "from": "Motorcycle",
|
| 151 |
-
# "to": "Engine",
|
| 152 |
-
# "type": "composition",
|
| 153 |
-
# "label": "has",
|
| 154 |
-
# "multiplicity_from": "1",
|
| 155 |
-
# "multiplicity_to": "1"
|
| 156 |
-
# },
|
| 157 |
-
# {
|
| 158 |
-
# "from": "Car",
|
| 159 |
-
# "to": "TransmissionType",
|
| 160 |
-
# "type": "association",
|
| 161 |
-
# "label": "uses",
|
| 162 |
-
# "multiplicity_from": "1",
|
| 163 |
-
# "multiplicity_to": "1"
|
| 164 |
-
# },
|
| 165 |
-
# {
|
| 166 |
-
# "from": "Vehicle",
|
| 167 |
-
# "to": "FuelType",
|
| 168 |
-
# "type": "association",
|
| 169 |
-
# "label": "uses",
|
| 170 |
-
# "multiplicity_from": "1",
|
| 171 |
-
# "multiplicity_to": "1"
|
| 172 |
-
# },
|
| 173 |
-
# {
|
| 174 |
-
# "from": "GarageService",
|
| 175 |
-
# "to": "VehicleService",
|
| 176 |
-
# "type": "realization",
|
| 177 |
-
# "label": "implements"
|
| 178 |
-
# },
|
| 179 |
-
# {
|
| 180 |
-
# "from": "GarageService",
|
| 181 |
-
# "to": "Vehicle",
|
| 182 |
-
# "type": "dependency",
|
| 183 |
-
# "label": "services",
|
| 184 |
-
# "multiplicity_from": "1",
|
| 185 |
-
# "multiplicity_to": "*"
|
| 186 |
-
# }
|
| 187 |
-
# ]
|
| 188 |
-
# }
|
| 189 |
-
|
| 190 |
-
# Returns:
|
| 191 |
-
# str: The filepath to the generated PNG image file.
|
| 192 |
-
# """
|
| 193 |
-
# try:
|
| 194 |
-
# if not json_input.strip():
|
| 195 |
-
# return "Error: Empty input"
|
| 196 |
-
|
| 197 |
-
# data = json.loads(json_input)
|
| 198 |
-
|
| 199 |
-
# if 'classes' not in data:
|
| 200 |
-
# raise ValueError("Missing required field: classes")
|
| 201 |
-
|
| 202 |
-
# # Configuración del diagrama con espaciado reducido
|
| 203 |
-
# dot = graphviz.Digraph(comment='Class Diagram')
|
| 204 |
-
# dot.attr(rankdir='TB', bgcolor='white', pad='0.5', nodesep='0.8', ranksep='1.2')
|
| 205 |
-
# dot.attr('node', shape='plaintext', fontname='Arial', fontsize='11')
|
| 206 |
-
# dot.attr('edge', color='black', fontname='Arial', fontsize='9', minlen='1')
|
| 207 |
-
|
| 208 |
-
# classes = data.get('classes', [])
|
| 209 |
-
# relationships = data.get('relationships', [])
|
| 210 |
-
|
| 211 |
-
# for cls in classes:
|
| 212 |
-
# class_name = cls.get('name')
|
| 213 |
-
# class_type = cls.get('type', 'class')
|
| 214 |
-
# attributes = cls.get('attributes', [])
|
| 215 |
-
# methods = cls.get('methods', [])
|
| 216 |
-
|
| 217 |
-
# if not class_name:
|
| 218 |
-
# continue
|
| 219 |
-
|
| 220 |
-
# # Crear tabla HTML para estructura de clase
|
| 221 |
-
# html_label = '<TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" CELLPADDING="5" BGCOLOR="white">'
|
| 222 |
-
|
| 223 |
-
# # Header con nombre de clase y estereotipo
|
| 224 |
-
# if class_type == 'abstract':
|
| 225 |
-
# html_label += f'<TR><TD ALIGN="CENTER"><B><<abstract>><BR/>{class_name}</B></TD></TR>'
|
| 226 |
-
# elif class_type == 'interface':
|
| 227 |
-
# html_label += f'<TR><TD ALIGN="CENTER"><B><<interface>><BR/>{class_name}</B></TD></TR>'
|
| 228 |
-
# elif class_type == 'enum':
|
| 229 |
-
# html_label += f'<TR><TD ALIGN="CENTER"><B><<enumeration>><BR/>{class_name}</B></TD></TR>'
|
| 230 |
-
# else:
|
| 231 |
-
# html_label += f'<TR><TD ALIGN="CENTER"><B>{class_name}</B></TD></TR>'
|
| 232 |
-
|
| 233 |
-
# # Línea separadora después del nombre
|
| 234 |
-
# html_label += '<HR/>'
|
| 235 |
-
|
| 236 |
-
# # Sección de atributos
|
| 237 |
-
# if attributes:
|
| 238 |
-
# for attr in attributes:
|
| 239 |
-
# visibility = attr.get('visibility', '+')
|
| 240 |
-
# name = attr.get('name', '')
|
| 241 |
-
# attr_type = attr.get('type', '')
|
| 242 |
-
# is_static = attr.get('static', False)
|
| 243 |
-
|
| 244 |
-
# line = f"{visibility} {name}"
|
| 245 |
-
# if attr_type:
|
| 246 |
-
# line += f" : {attr_type}"
|
| 247 |
-
# if is_static:
|
| 248 |
-
# line = f"<U>{line}</U>" # Subrayado para elementos estáticos
|
| 249 |
-
|
| 250 |
-
# html_label += f'<TR><TD ALIGN="LEFT">{line}</TD></TR>'
|
| 251 |
-
# else:
|
| 252 |
-
# # Espacio vacío si no hay atributos
|
| 253 |
-
# html_label += '<TR><TD ALIGN="LEFT"> </TD></TR>'
|
| 254 |
-
|
| 255 |
-
# # Línea separadora entre atributos y métodos
|
| 256 |
-
# html_label += '<HR/>'
|
| 257 |
-
|
| 258 |
-
# # Sección de métodos
|
| 259 |
-
# if methods:
|
| 260 |
-
# for method in methods:
|
| 261 |
-
# visibility = method.get('visibility', '+')
|
| 262 |
-
# name = method.get('name', '')
|
| 263 |
-
# parameters = method.get('parameters', [])
|
| 264 |
-
# return_type = method.get('return_type', 'void')
|
| 265 |
-
# is_static = method.get('static', False)
|
| 266 |
-
# is_abstract = method.get('abstract', False)
|
| 267 |
-
|
| 268 |
-
# line = f"{visibility} {name}("
|
| 269 |
-
# if parameters:
|
| 270 |
-
# params = []
|
| 271 |
-
# for param in parameters:
|
| 272 |
-
# param_name = param.get('name', '')
|
| 273 |
-
# param_type = param.get('type', '')
|
| 274 |
-
# params.append(f"{param_name}: {param_type}")
|
| 275 |
-
# line += ", ".join(params)
|
| 276 |
-
# line += f") : {return_type}"
|
| 277 |
-
|
| 278 |
-
# if is_static:
|
| 279 |
-
# line = f"<U>{line}</U>" # Subrayado para métodos estáticos
|
| 280 |
-
# if is_abstract:
|
| 281 |
-
# line = f"<I>{line}</I>" # Cursiva para métodos abstractos
|
| 282 |
-
|
| 283 |
-
# html_label += f'<TR><TD ALIGN="LEFT">{line}</TD></TR>'
|
| 284 |
-
# else:
|
| 285 |
-
# # Espacio vacío si no hay métodos
|
| 286 |
-
# html_label += '<TR><TD ALIGN="LEFT"> </TD></TR>'
|
| 287 |
-
|
| 288 |
-
# html_label += '</TABLE>'
|
| 289 |
-
|
| 290 |
-
# # Agregar nodo con la tabla HTML
|
| 291 |
-
# dot.node(class_name, f'<{html_label}>')
|
| 292 |
-
|
| 293 |
-
# # Procesar relaciones con líneas rectas
|
| 294 |
-
# for relationship in relationships:
|
| 295 |
-
# from_class = relationship.get('from')
|
| 296 |
-
# to_class = relationship.get('to')
|
| 297 |
-
# rel_type = relationship.get('type', 'association')
|
| 298 |
-
# label = relationship.get('label', '')
|
| 299 |
-
# multiplicity_from = relationship.get('multiplicity_from', '')
|
| 300 |
-
# multiplicity_to = relationship.get('multiplicity_to', '')
|
| 301 |
-
|
| 302 |
-
# if not from_class or not to_class:
|
| 303 |
-
# continue
|
| 304 |
-
|
| 305 |
-
# edge_attrs = {
|
| 306 |
-
# 'splines': 'ortho', # Líneas estrictamente ortogonales (solo horizontales/verticales)
|
| 307 |
-
# 'concentrate': 'false', # Evita que las líneas se combinen
|
| 308 |
-
# 'constraint': 'true' # Mantiene la estructura jerárquica
|
| 309 |
-
# }
|
| 310 |
-
|
| 311 |
-
# if label:
|
| 312 |
-
# edge_attrs['label'] = label
|
| 313 |
-
|
| 314 |
-
# if multiplicity_from:
|
| 315 |
-
# edge_attrs['taillabel'] = multiplicity_from
|
| 316 |
-
|
| 317 |
-
# if multiplicity_to:
|
| 318 |
-
# edge_attrs['headlabel'] = multiplicity_to
|
| 319 |
-
|
| 320 |
-
# # Configurar estilos de flecha según el tipo de relación
|
| 321 |
-
# if rel_type == 'inheritance':
|
| 322 |
-
# edge_attrs['arrowhead'] = 'empty'
|
| 323 |
-
# edge_attrs['color'] = 'black'
|
| 324 |
-
# elif rel_type == 'composition':
|
| 325 |
-
# edge_attrs['arrowhead'] = 'normal'
|
| 326 |
-
# edge_attrs['arrowtail'] = 'diamond'
|
| 327 |
-
# edge_attrs['dir'] = 'both'
|
| 328 |
-
# edge_attrs['color'] = 'black'
|
| 329 |
-
# elif rel_type == 'aggregation':
|
| 330 |
-
# edge_attrs['arrowhead'] = 'normal'
|
| 331 |
-
# edge_attrs['arrowtail'] = 'odiamond'
|
| 332 |
-
# edge_attrs['dir'] = 'both'
|
| 333 |
-
# edge_attrs['color'] = 'black'
|
| 334 |
-
# elif rel_type == 'realization':
|
| 335 |
-
# edge_attrs['arrowhead'] = 'empty'
|
| 336 |
-
# edge_attrs['style'] = 'dashed'
|
| 337 |
-
# edge_attrs['color'] = 'black'
|
| 338 |
-
# elif rel_type == 'dependency':
|
| 339 |
-
# edge_attrs['arrowhead'] = 'normal'
|
| 340 |
-
# edge_attrs['style'] = 'dashed'
|
| 341 |
-
# edge_attrs['color'] = 'black'
|
| 342 |
-
# else: # association
|
| 343 |
-
# edge_attrs['arrowhead'] = 'normal'
|
| 344 |
-
# edge_attrs['color'] = 'black'
|
| 345 |
-
|
| 346 |
-
# dot.edge(from_class, to_class, **edge_attrs)
|
| 347 |
-
|
| 348 |
-
# # Renderizar el diagrama
|
| 349 |
-
# with NamedTemporaryFile(delete=False, suffix=f'.{output_format}') as tmp:
|
| 350 |
-
# dot.render(tmp.name, format=output_format, cleanup=True)
|
| 351 |
-
# return f"{tmp.name}.{output_format}"
|
| 352 |
-
|
| 353 |
-
# except json.JSONDecodeError:
|
| 354 |
-
# return "Error: Invalid JSON format"
|
| 355 |
-
# except Exception as e:
|
| 356 |
-
# return f"Error: {str(e)}"
|
| 357 |
-
|
| 358 |
import graphviz
|
| 359 |
import json
|
| 360 |
from tempfile import NamedTemporaryFile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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