diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 87dfe6cd..6aa9e662 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from typing import Optional, List, Tuple, Union +from typing import Optional, List, Dict, Tuple, Union from dataclasses import dataclass, field, InitVar from pathlib import Path @@ -94,6 +94,7 @@ class Connector: type: Optional[MultilineHypertext] = None subtype: Optional[MultilineHypertext] = None pincount: Optional[int] = None + additional_parameters: Optional[Dict] = None image: Optional[Image] = None notes: Optional[MultilineHypertext] = None pinlabels: List[Pin] = field(default_factory=list) @@ -182,6 +183,7 @@ class Cable: color: Optional[Color] = None wirecount: Optional[int] = None shield: Union[bool, Color] = False + additional_parameters: Optional[Dict] = None image: Optional[Image] = None notes: Optional[MultilineHypertext] = None colors: List[Colors] = field(default_factory=list) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 14f96b06..486dfdd9 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -12,7 +12,7 @@ from wireviz.DataClasses import Connector, Cable from wireviz.wv_colors import get_color_hex from wireviz.wv_gv_html import nested_html_table, html_colorbar, html_image, \ - html_caption, remove_links, html_line_breaks, bom_bubble + html_caption, remove_links, html_line_breaks, bom_bubble, nested_html_table_dict from wireviz.wv_bom import manufacturer_info_field, \ get_additional_component_table, bom_list, generate_bom from wireviz.wv_html import generate_html_output @@ -122,11 +122,13 @@ def create_graph(self) -> Graph: connector.color, html_colorbar(connector.color)], [f'P/N: {remove_links(connector.pn)}' if connector.pn else None, html_line_breaks(manufacturer_info_field(connector.manufacturer, connector.mpn))] if self.show_part_numbers else None, + nested_html_table_dict(connector.additional_parameters), '' if connector.style != 'simple' else None, [html_image(connector.image)], [html_caption(connector.image)]] rows.append(get_additional_component_table(self, connector)) rows.append([html_line_breaks(connector.notes)]) + html.extend(nested_html_table(rows)) if connector.style != 'simple': @@ -208,6 +210,7 @@ def create_graph(self) -> Graph: html_line_breaks(manufacturer_info_field( cable.manufacturer if not isinstance(cable.manufacturer, list) else None, cable.mpn if not isinstance(cable.mpn, list) else None))], + nested_html_table_dict(cable.additional_parameters), '', [html_image(cable.image)], [html_caption(cable.image)]] diff --git a/src/wireviz/wv_gv_html.py b/src/wireviz/wv_gv_html.py index 87b24962..a54f0020 100644 --- a/src/wireviz/wv_gv_html.py +++ b/src/wireviz/wv_gv_html.py @@ -1,12 +1,25 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from typing import List, Union +from typing import List, Dict, Union import re from wireviz.wv_colors import translate_color from wireviz.wv_helper import remove_links +def nested_html_table_dict(rows): + if isinstance(rows, Dict): + html = [] + html.append('
{key} | ') + html.append(f'{value} |