graflo.plot.merge¶
Draw a merge preview: the declaration graph, with its conflicts marked.
The picture a
:class:~graflo.architecture.evolution.preview.MergePreview is asking to be:
each side's classes down its own column, the merged names between them, and
every declaration as an edge. Classes are drawn as tables — one row per
attribute, each its own Graphviz port — so a property rename lands on the row
it renames rather than somewhere on the box. That is the whole reason to draw
this at all: class_A - attr_a - attr_b - class_B is a statement about
attributes, and a diagram that only draws classes cannot show it.
Findings colour what they name and are numbered into a legend, so the picture says where as well as what. A refusal — the one merge actually raised — is red; everything the structural pass found on its own is amber; the declarations a completion suggests are dashed green, because a refusal that carries its own fix should look like one.
:func:build_preview_graph returns a plain :mod:networkx graph and needs no
Graphviz, so what is drawn can be asserted directly;
:func:plot_merge_preview is the half that writes a file.
Attributes¶
EDGE_STYLE = {'member': {'style': 'solid', 'color': '#2C3E50', 'penwidth': '1.4'}, 'map': {'style': 'dashed', 'color': '#1F5FBF'}, 'property_map': {'style': 'dashed', 'color': '#1F5FBF', 'penwidth': '0.7'}, 'property_equivalence': {'style': 'dotted', 'color': '#6B4C9A', 'penwidth': '0.9'}, 'suggested': {'style': 'dashed', 'color': '#1E8449', 'penwidth': '1.2'}}
module-attribute
¶
HEADER_COLOR = {'left': '#B7D1DF', 'right': '#BEDFC8', 'merged': '#FFE5B4', 'canonical': '#DDD0E5', 'ghost': '#E4E1D7', 'relation': '#FFFFFF'}
module-attribute
¶
SEVERITY_COLOR = {'refusal': '#C0392B', 'possible': '#E67E22', 'note': '#7F8C8D'}
module-attribute
¶
__all__ = ['EDGE_STYLE', 'HEADER_COLOR', 'SEVERITY_COLOR', 'build_preview_graph', 'plot_merge_preview']
module-attribute
¶
Classes¶
Functions:¶
build_preview_graph(preview, *, max_rows=12, legend=True)
¶
The preview as a networkx graph, styled but not yet drawn.
Only classes, relations and merged names become nodes: attributes are
rows on their owner, addressed by port. Every node carries the preview id
it came from as preview_id, so a caller can map back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preview
|
MergePreview
|
What :func: |
required |
max_rows
|
int
|
Attribute rows to draw per class before summarising the rest. |
12
|
legend
|
bool
|
Whether to include the findings table. |
True
|
Returns:
| Type | Description |
|---|---|
MultiDiGraph
|
A graph whose node and edge attributes are Graphviz attributes. |
Source code in graflo/plot/merge.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
plot_merge_preview(preview, path, *, output_format=None, prog='dot', dpi=None, max_rows=12, legend=True)
¶
Draw preview to path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preview
|
MergePreview
|
What |
required |
path
|
str | PathLike[str]
|
Where to write; the suffix picks the format (svg/pdf/png/dot). |
required |
output_format
|
str | None
|
Override the format the suffix implies. |
None
|
prog
|
str
|
Graphviz layout program. |
'dot'
|
dpi
|
int | None
|
Raster resolution, for |
None
|
max_rows
|
int
|
Attribute rows per class before the rest are summarised. |
12
|
legend
|
bool
|
Whether to draw the findings table. |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
The path written. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
pygraphviz or system Graphviz is not installed. |
ValueError
|
The format is not one this can write. |