diff --git a/docs/syntax.md b/docs/syntax.md index 7dbc6f8..005883a 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -329,7 +329,7 @@ Alternatively items can be added to just the BOM by putting them in the section manufacturer: # manufacturer name ``` -## Tweak entries +## GraphViz tweaking (experimental) ```yaml # Optional tweaking of the .gv output. @@ -342,15 +342,14 @@ Alternatively items can be added to just the BOM by putting them in the section # The leading string might be in "quotes" in # the .gv output. This leading string must be # followed by attributes in [square brackets]. - # Entries containing HTML in an attribute are + # Entries with an attribute containing HTML are # not supported. : # leading string of .gv entry : # attribute and its new value # Any number of attributes can be overridden # for each entry - append: # single or list of .gv entries to append - # strings to append might have multiple lines + append: # string or list of strings to append to the .gv output ``` ## Colors diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 1d6c586..548a687 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -3,7 +3,7 @@ from graphviz import Graph from collections import Counter -from typing import List, Union +from typing import Any, List, Union from dataclasses import dataclass from pathlib import Path from itertools import zip_longest @@ -345,9 +345,9 @@ class Harness: dot.node(cable.name, label=f'<\n{html}\n>', shape='box', style=style, fillcolor=translate_color(bgcolor, "HEX")) - def typecheck(name: str, var, type) -> None: - if not isinstance(var, type): - raise Exception(f'Unexpected value type of {name}: {var}') + def typecheck(name: str, value: Any, expect: type) -> None: + if not isinstance(value, expect): + raise Exception(f'Unexpected value type of {name}: Expected {expect}, got {type(value)}\n{value}') # TODO?: Differ between override attributes and HTML? if self.tweak.override is not None: @@ -380,7 +380,7 @@ class Harness: typecheck(f'tweak.append[{i}]', element, str) dot.body.extend(self.tweak.append) else: - typecheck(f'tweak.append', self.tweak.append, str) + typecheck('tweak.append', self.tweak.append, str) dot.body.append(self.tweak.append) return dot