Skip to content

Commit

Permalink
docs: Add docs and images
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Aug 13, 2024
1 parent 64edbcb commit 0338310
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
4 changes: 3 additions & 1 deletion capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ def register_data_flow_view() -> None:

def register_exchange_item_class_tree_view() -> None:

supported_classes: list[SupportedClass] = [
supported_classes: list[
tuple[type[common.GenericElement], set[DiagramType], dict[str, t.Any]]
] = [
(oa.CommunicationMean, {DiagramType.OAB}, {}),
(
fa.ComponentExchange,
Expand Down
4 changes: 2 additions & 2 deletions capellambse_context_diagrams/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def _create_diagram(self, params: dict[str, t.Any]) -> cdiagram.Diagram:


class ExchangeItemClassTreeViewDiagram(ContextDiagram):
"""An automatically generated ExchangeExchangeItemClassTreeViewDiagram."""
"""An automatically generated ExchangeItemClassTreeViewDiagram."""

@property
def uuid(self) -> str: # type: ignore
Expand All @@ -700,7 +700,7 @@ def uuid(self) -> str: # type: ignore

@property
def name(self) -> str: # type: ignore
return f"Element Relation View of {self.target.name}"
return f"Exchange Item Class Tree View of {self.target.name}"

def _create_diagram(self, params: dict[str, t.Any]) -> cdiagram.Diagram:
data = exchange_item_class_tree_view.collector(self, params)
Expand Down
34 changes: 34 additions & 0 deletions docs/exchange_item_class_tree_view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
~ SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
~ SPDX-License-Identifier: Apache-2.0
-->

# Exchange Item Class Tree View

The `ExchangeItemClassTreeView` visualizes the hierarchical structure of exchange items and the relationships between their associated classes in a tree view. You can access `.exchange_item_class_tree_view` on any `fa.ComponentExchange`. Data collection starts on the allocated exchange items and collects the associated classes through their exchange item elements.

??? example "Exchange Item Class Tree View of C 28"

``` py
import capellambse

model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
diag = model.by_uuid("0ab202d7-6497-4b78-9d13-fd7c9a75486c").exchange_item_class_tree_view
diag.render("svgdiagram").save(pretty=True)
```
<figure markdown>
<img src="../assets/images/Exchange Item Class Tree View of C 28.svg">
<figcaption>[LAB] Exchange Item Class Tree View of C 28</figcaption>
</figure>

## Known Issues

One known issue with the current implementation is related to the routing of edges for ExchangeItemElements. The edges might not be routed optimally in certain cases due to the limitations of ELK'S edge routing algorithms.

This issue could potentially be resolved when Libavoid for ELK becomes publicly available. Libavoid is an advanced edge routing library that offers object-avoiding orthogonal and polyline connector routing, which could improve the layout of the edges in the diagram. At that point the exchange item element labels will be added to the diagram as well.

## Check out the code

To understand the collection have a look into the
[`exchange_item_class_tree_view`][capellambse_context_diagrams.collectors.exchange_item_class_tree_view]
module.
9 changes: 9 additions & 0 deletions docs/gen_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
realization_comp_uuid = "b9f9a83c-fb02-44f7-9123-9d86326de5f1"
data_flow_uuid = "3b83b4ba-671a-4de8-9c07-a5c6b1d3c422"
derived_uuid = "47c3130b-ec39-4365-a77a-5ab6365d1e2e"
exchange_item_class_tree_uuid = "0ab202d7-6497-4b78-9d13-fd7c9a75486c"


def generate_index_images() -> None:
Expand Down Expand Up @@ -192,6 +193,13 @@ def generate_interface_with_hide_interface_image():
print(diag.render("svg", **params), file=fd)


def generate_exchange_item_class_tree_images() -> None:
obj = model.by_uuid(exchange_item_class_tree_uuid)
diag = obj.exchange_item_class_tree_view
with mkdocs_gen_files.open(f"{str(dest / diag.name)}.svg", "w") as fd:
print(diag.render("svg", transparent_background=False), file=fd)


generate_index_images()
generate_hierarchy_image()
generate_symbol_images()
Expand Down Expand Up @@ -219,3 +227,4 @@ def generate_interface_with_hide_interface_image():
generate_derived_image()
generate_interface_with_hide_functions_image()
generate_interface_with_hide_interface_image()
generate_exchange_item_class_tree_images()
1 change: 0 additions & 1 deletion tests/test_exchange_item_class_tree_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ def test_exchange_item_class_tree_views(
obj = model.by_uuid(uuid)

diag = obj.exchange_item_class_tree_view
diag.render("svgdiagram").save(pretty=True)

assert diag.render(fmt)

0 comments on commit 0338310

Please sign in to comment.