diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 89bff69..6b9c42c 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -20,6 +20,7 @@ class Connector: pincount: Optional[int] = None image: Optional[str] = None image_scale: Optional[str] = "FALSE" + image_size: List[Any] = field(default_factory=list) caption: Optional[str] = None notes: Optional[str] = None pinlabels: List[Any] = field(default_factory=list) @@ -96,6 +97,7 @@ class Cable: shield: bool = False image: Optional[str] = None image_scale: Optional[str] = "FALSE" + image_size: List[Any] = field(default_factory=list) caption: Optional[str] = None notes: Optional[str] = None colors: List[Any] = field(default_factory=list) diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index f8a9cad..75c860f 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -58,11 +58,22 @@ def nested_html_table(rows): def html_image(node): if not node.image: return None - return f'''''' + return f'''''' \ + f'''''' def html_caption(node): return f'''{html_line_breaks(node.caption)}''' if node.caption else None +def html_size_attr(size): + # Return Graphviz HTML attributes to specify minimum size of a TABLE or TD object + # size: List of values where only these are used: + # - First value is minimum width of object in points, an int value in the range 1-65535. (Default 0 = none) + # - Second value is minimum height of the object in points, an int value in the range 1-65535. (Default 0 = none) + if not size or not isinstance(size, list): + return '' + return ((f' width="{size[0]}"' if len(size) > 0 and size[0] else '') + + (f' height="{size[1]}"' if len(size) > 1 and size[1] else '')) + def expand(yaml_data): # yaml_data can be: