diff --git a/docs/syntax.md b/docs/syntax.md index 1074cd02..d1cb07c7 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -323,6 +323,7 @@ Parts can be added to a connector or cable in the section ` # manufacturer part number supplier: # supplier name spn: # supplier part number + bgcolor: # Background color of entry in diagram component box ``` Alternatively items can be added to just the BOM by putting them in the section `` above. diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 25bbe34e..cb2aba12 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -114,6 +114,7 @@ class AdditionalComponent: qty: float = 1 unit: Optional[str] = None qty_multiplier: Union[ConnectorMultiplier, CableMultiplier, None] = None + bgcolor: Optional[Color] = None @property def description(self) -> str: diff --git a/src/wireviz/wv_bom.py b/src/wireviz/wv_bom.py index bd7aedeb..418bce1e 100644 --- a/src/wireviz/wv_bom.py +++ b/src/wireviz/wv_bom.py @@ -5,9 +5,9 @@ from itertools import groupby from typing import Any, Dict, List, Optional, Tuple, Union -from wireviz.DataClasses import AdditionalComponent, Connector, Cable +from wireviz.DataClasses import AdditionalComponent, Cable, Color, Connector from wireviz.wv_colors import translate_color -from wireviz.wv_gv_html import html_line_breaks +from wireviz.wv_gv_html import html_bgcolor_attr, html_line_breaks from wireviz.wv_helper import clean_whitespace BOM_COLUMNS_ALWAYS = ('id', 'description', 'qty', 'unit', 'designators') @@ -36,6 +36,7 @@ def get_additional_component_table(harness: "Harness", component: Union[Connecto common_args = { 'qty': part.qty * component.get_qty_multiplier(part.qty_multiplier), 'unit': part.unit, + 'bgcolor': part.bgcolor, } if harness.options.mini_bom_mode: id = get_bom_index(harness.bom(), bom_entry_key({**asdict(part), 'description': part.description})) @@ -158,6 +159,7 @@ def component_table_entry( type: str, qty: Union[int, float], unit: Optional[str] = None, + bgcolor: Optional[Color] = None, pn: Optional[str] = None, manufacturer: Optional[str] = None, mpn: Optional[str] = None, @@ -177,7 +179,7 @@ def component_table_entry( + (', '.join([pn for pn in part_number_list if pn]))) # format the above output as left aligned text in a single visible cell # indent is set to two to match the indent in the generated html table - return f''' + return f'''
{html_line_breaks(output)}
'''