From 9435fc2c2fee80ccec920d8fa345b85e4eb0e4a5 Mon Sep 17 00:00:00 2001 From: KV Date: Sat, 25 May 2024 17:43:29 +0200 Subject: [PATCH 01/36] Create PR to collect changes for v0.4.1-rc --- src/wireviz/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wireviz/__init__.py b/src/wireviz/__init__.py index b70a2a71..7b328c85 100644 --- a/src/wireviz/__init__.py +++ b/src/wireviz/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Please don't import anything in this file to avoid issues when it is imported in setup.py -__version__ = "0.4" +__version__ = "0.4.1-dev" CMD_NAME = "wireviz" # Lower case command and module name APP_NAME = "WireViz" # Application name in texts meant to be human readable From 77061a065606ee90441e7278458cb040386e340e Mon Sep 17 00:00:00 2001 From: KV Date: Thu, 16 May 2024 00:32:31 +0200 Subject: [PATCH 02/36] Handle OSError(errno=EINVAL) that might be raised in Windows (#346) In Windows might OSError(errno=EINVAL) be raised instead of the already catched exceptions in some cases (depending on the Python version). Suggested fix posted by JarrettR in https://github.com/wireviz/WireViz/issues/344#issuecomment-2113476151 Co-authored-by: JarrettR --- src/wireviz/wireviz.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index db692419..5fc3ee14 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -408,11 +408,12 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path): yaml_str = open_file_read(yaml_path).read() except (FileNotFoundError, OSError) as e: # if inp is a long YAML string, Pathlib will raise OSError: [errno.ENAMETOOLONG] + # (in Windows, it seems OSError [errno.EINVAL] might be raised in some cases) # when trying to expand and resolve it as a path. # Catch this error, but raise any others - from errno import ENAMETOOLONG + from errno import EINVAL, ENAMETOOLONG - if type(e) is OSError and e.errno != ENAMETOOLONG: + if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG): raise e # file does not exist; assume inp is a YAML string yaml_str = inp From a89d04d8ca6761ad77ce3621cf6d95489e4cd207 Mon Sep 17 00:00:00 2001 From: KV Date: Thu, 16 May 2024 16:22:19 +0200 Subject: [PATCH 03/36] Add package_data to to setup() call in setup.py (#347) Specify all HTML files under templates folder to be included as package data files. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 8cdd4864..97f61aa9 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ keywords="cable connector hardware harness wiring wiring-diagram wiring-harness", url=APP_URL, package_dir={"": "src"}, + package_data={CMD_NAME: ["templates/*.html"]}, packages=find_packages("src"), entry_points={ "console_scripts": [ From 557122c4a35d61aee3d1b76f25225e00d1965eb8 Mon Sep 17 00:00:00 2001 From: KV Date: Wed, 22 May 2024 02:22:42 +0200 Subject: [PATCH 04/36] Look-up mated connectors before mate processing (#358) Symptom reported in #355: Unable to connect an arrow (mate) to pins higher than 1 without failing: ValueError: X is not in list Bug: The code processing mates used a mix of repeated connector look-ups and local connector variables, and one variable was used before it was assigned the correct value. Fix: The local connector variables are now both assigned initially before processing each mate, and used when processing instead of repeated connector look-ups. --- src/wireviz/Harness.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 30468a6a..51287a2f 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -595,6 +595,7 @@ def typecheck(name: str, value: Any, expect: type) -> None: typecheck("tweak.append", self.tweak.append, str) dot.body.append(self.tweak.append) + # TODO: All code below until "return dot" must be moved above all tweak processing! for mate in self.mates: if mate.shape[0] == "<" and mate.shape[-1] == ">": dir = "both" @@ -613,29 +614,18 @@ def typecheck(name: str, value: Any, expect: type) -> None: raise Exception(f"{mate} is an unknown mate") from_connector = self.connectors[mate.from_name] - if ( - isinstance(mate, MatePin) - and self.connectors[mate.from_name].style != "simple" - ): + to_connector = self.connectors[mate.to_name] + if isinstance(mate, MatePin) and from_connector.style != "simple": from_pin_index = from_connector.pins.index(mate.from_pin) from_port_str = f":p{from_pin_index+1}r" else: # MateComponent or style == 'simple' from_port_str = "" - if ( - isinstance(mate, MatePin) - and self.connectors[mate.to_name].style != "simple" - ): + if isinstance(mate, MatePin) and to_connector.style != "simple": to_pin_index = to_connector.pins.index(mate.to_pin) - to_port_str = ( - f":p{to_pin_index+1}l" - if isinstance(mate, MatePin) - and self.connectors[mate.to_name].style != "simple" - else "" - ) + to_port_str = f":p{to_pin_index+1}l" else: # MateComponent or style == 'simple' to_port_str = "" code_from = f"{mate.from_name}{from_port_str}:e" - to_connector = self.connectors[mate.to_name] code_to = f"{mate.to_name}{to_port_str}:w" dot.attr("edge", color=color, style="dashed", dir=dir) From 82751e439ea70bd9095b96fb1adf3a0a59bcf111 Mon Sep 17 00:00:00 2001 From: KV Date: Wed, 29 May 2024 22:49:08 +0200 Subject: [PATCH 05/36] Move mates processing above tweak processing (#358) Bug: Not all generated dot output could be changed by tweak entries. Seen in https://github.com/wireviz/WireViz/issues/325#issuecomment-2116395221 Tweak processing must be the very last dot producing code to enable tweaking any dot output. Fix: Move all other dot producing code above Tweak processing. --- src/wireviz/Harness.py | 70 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 51287a2f..5ef7ad02 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -530,6 +530,38 @@ def create_graph(self) -> Graph: fillcolor=translate_color(bgcolor, "HEX"), ) + # mates + for mate in self.mates: + if mate.shape[-1] == ">": + dir = "both" if mate.shape[0] == "<" else "forward" + else: + dir = "back" if mate.shape[0] == "<" else "none" + + if isinstance(mate, MatePin): + color = "#000000" + elif isinstance(mate, MateComponent): + color = "#000000:#000000" + else: + raise Exception(f"{mate} is an unknown mate") + + from_connector = self.connectors[mate.from_name] + to_connector = self.connectors[mate.to_name] + if isinstance(mate, MatePin) and from_connector.style != "simple": + from_pin_index = from_connector.pins.index(mate.from_pin) + from_port_str = f":p{from_pin_index+1}r" + else: # MateComponent or style == 'simple' + from_port_str = "" + if isinstance(mate, MatePin) and to_connector.style != "simple": + to_pin_index = to_connector.pins.index(mate.to_pin) + to_port_str = f":p{to_pin_index+1}l" + else: # MateComponent or style == 'simple' + to_port_str = "" + code_from = f"{mate.from_name}{from_port_str}:e" + code_to = f"{mate.to_name}{to_port_str}:w" + + dot.attr("edge", color=color, style="dashed", dir=dir) + dot.edge(code_from, code_to) + def typecheck(name: str, value: Any, expect: type) -> None: if not isinstance(value, expect): raise Exception( @@ -595,41 +627,9 @@ def typecheck(name: str, value: Any, expect: type) -> None: typecheck("tweak.append", self.tweak.append, str) dot.body.append(self.tweak.append) - # TODO: All code below until "return dot" must be moved above all tweak processing! - for mate in self.mates: - if mate.shape[0] == "<" and mate.shape[-1] == ">": - dir = "both" - elif mate.shape[0] == "<": - dir = "back" - elif mate.shape[-1] == ">": - dir = "forward" - else: - dir = "none" - - if isinstance(mate, MatePin): - color = "#000000" - elif isinstance(mate, MateComponent): - color = "#000000:#000000" - else: - raise Exception(f"{mate} is an unknown mate") - - from_connector = self.connectors[mate.from_name] - to_connector = self.connectors[mate.to_name] - if isinstance(mate, MatePin) and from_connector.style != "simple": - from_pin_index = from_connector.pins.index(mate.from_pin) - from_port_str = f":p{from_pin_index+1}r" - else: # MateComponent or style == 'simple' - from_port_str = "" - if isinstance(mate, MatePin) and to_connector.style != "simple": - to_pin_index = to_connector.pins.index(mate.to_pin) - to_port_str = f":p{to_pin_index+1}l" - else: # MateComponent or style == 'simple' - to_port_str = "" - code_from = f"{mate.from_name}{from_port_str}:e" - code_to = f"{mate.to_name}{to_port_str}:w" - - dot.attr("edge", color=color, style="dashed", dir=dir) - dot.edge(code_from, code_to) + # Tweak processing above must be the last before returning dot. + # Please don't insert any code that might change the dot contents + # after tweak processing. return dot From 7ae3fb33fdd82a8a32f0765ea847bbfac94661e1 Mon Sep 17 00:00:00 2001 From: KV Date: Thu, 23 May 2024 17:52:32 +0200 Subject: [PATCH 06/36] Use output_name as default title (#361) The CLI handling code was redesigned for v0.4 and it seems the code to assign a default title from v0.3.1 has been messed up. This bug has not been triggered by build_examples.py due to it seems to call the parse() function differently. The output_name should be used as default title when present. This will fix the #360 bug report. --- src/wireviz/wireviz.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index 5fc3ee14..0a07ab62 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -20,6 +20,8 @@ smart_file_resolve, ) +from . import APP_NAME + def parse( inp: Union[Path, str, Dict], @@ -117,10 +119,7 @@ def parse( # When title is not given, either deduce it from filename, or use default text. if "title" not in harness.metadata: - if yaml_file is None: - harness.metadata["title"] = "WireViz diagram and BOM" - else: - harness.metadata["title"] = Path(yaml_file).stem + harness.metadata["title"] = output_name or f"{APP_NAME} diagram and BOM" # add items # parse YAML input file ==================================================== From a5f91e91b7bb83a4fcae21e215c6b0892474292c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Ad=C3=A4mmer?= Date: Fri, 24 May 2024 07:51:36 +0200 Subject: [PATCH 07/36] Add missing import of embed_svg_images (#363) Resort module import: Co-authored-by: kvid --- src/wireviz/Harness.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 5ef7ad02..fb56c8a5 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -20,7 +20,7 @@ Tweak, Side, ) -from wireviz.svgembed import embed_svg_images_file +from wireviz.svgembed import embed_svg_images, embed_svg_images_file from wireviz.wv_bom import ( HEADER_MPN, HEADER_PN, From 2336231d3e0f25247702b7d45f8e0d795167f716 Mon Sep 17 00:00:00 2001 From: KV Date: Sat, 25 May 2024 16:02:38 +0200 Subject: [PATCH 08/36] Update APP_URL (#364) The project was moved into the new organization 2023-05-30, but old URLs are still working due to automatic redirects by GitHub. https://github.com/wireviz/WireViz/issues/316#issuecomment-1568748914 --- docs/CHANGELOG.md | 86 ++++++++++++++++++++--------------------- docs/CONTRIBUTING.md | 4 +- docs/buildscript.md | 2 +- src/wireviz/__init__.py | 2 +- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2008945f..1ce418ca 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [0.4](https://github.com/formatc1702/WireViz/tree/v0.4) (2024-05-12) +## [0.4](https://github.com/wireviz/WireViz/tree/v0.4) (2024-05-12) ### Backward-incompatible changes - New syntax for autogenerated components ([#184](https://github.com/wireviz/WireViz/issues/184), [#186](https://github.com/wireviz/WireViz/pull/186)) @@ -25,60 +25,60 @@ - Minor adjustments ([#256](https://github.com/wireviz/WireViz/pull/256)) -## [0.3.2](https://github.com/formatc1702/WireViz/tree/v0.3.2) (2021-11-27) +## [0.3.2](https://github.com/wireviz/WireViz/tree/v0.3.2) (2021-11-27) ### Hotfix -- Adjust GraphViz generation code for compatibility with v0.18 of the `graphviz` Python package ([#258](https://github.com/formatc1702/WireViz/issues/258), [#261](https://github.com/formatc1702/WireViz/pull/261)) +- Adjust GraphViz generation code for compatibility with v0.18 of the `graphviz` Python package ([#258](https://github.com/wireviz/WireViz/issues/258), [#261](https://github.com/wireviz/WireViz/pull/261)) -## [0.3.1](https://github.com/formatc1702/WireViz/tree/v0.3.1) (2021-10-25) +## [0.3.1](https://github.com/wireviz/WireViz/tree/v0.3.1) (2021-10-25) ### Hotfix -- Assign generic harness title when using WireViz as a module and not specifying an output file name ([#253](https://github.com/formatc1702/WireViz/issues/253), [#254](https://github.com/formatc1702/WireViz/pull/254)) +- Assign generic harness title when using WireViz as a module and not specifying an output file name ([#253](https://github.com/wireviz/WireViz/issues/253), [#254](https://github.com/wireviz/WireViz/pull/254)) -## [0.3](https://github.com/formatc1702/WireViz/tree/v0.3) (2021-10-11) +## [0.3](https://github.com/wireviz/WireViz/tree/v0.3) (2021-10-11) ### New features -- Allow referencing a cable's/bundle's wires by color or by label ([#70](https://github.com/formatc1702/WireViz/issues/70), [#169](https://github.com/formatc1702/WireViz/issues/169), [#193](https://github.com/formatc1702/WireViz/issues/193), [#194](https://github.com/formatc1702/WireViz/pull/194)) -- Allow additional BOM items within components ([#50](https://github.com/formatc1702/WireViz/issues/50), [#115](https://github.com/formatc1702/WireViz/pull/115)) -- Add support for length units in cables and wires ([#7](https://github.com/formatc1702/WireViz/issues/7), [#196](https://github.com/formatc1702/WireViz/pull/196) (with work from [#161](https://github.com/formatc1702/WireViz/pull/161), [#162](https://github.com/formatc1702/WireViz/pull/162), [#171](https://github.com/formatc1702/WireViz/pull/171)), [#198](https://github.com/formatc1702/WireViz/pull/198), [#205](https://github.com/formatc1702/WireViz/issues/205). [#206](https://github.com/formatc1702/WireViz/pull/206)) -- Add option to define connector pin colors ([#53](https://github.com/formatc1702/WireViz/issues/53), [#141](https://github.com/formatc1702/WireViz/pull/141)) -- Remove HTML links from the input attributes ([#164](https://github.com/formatc1702/WireViz/pull/164)) -- Add harness metadata section ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214)) -- Add support for supplier and supplier part number information ([#240](https://github.com/formatc1702/WireViz/issues/240), [#241](https://github.com/formatc1702/WireViz/pull/241/)) -- Add graph rendering options (background colors, fontname, color name display style, ...) ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214)) -- Add support for background colors for cables and connectors, as well as for some individual cells ([#210](https://github.com/formatc1702/WireViz/issues/210), [#219](https://github.com/formatc1702/WireViz/pull/219)) -- Add optional tweaking of the .gv output ([#215](https://github.com/formatc1702/WireViz/pull/215)) (experimental) +- Allow referencing a cable's/bundle's wires by color or by label ([#70](https://github.com/wireviz/WireViz/issues/70), [#169](https://github.com/wireviz/WireViz/issues/169), [#193](https://github.com/wireviz/WireViz/issues/193), [#194](https://github.com/wireviz/WireViz/pull/194)) +- Allow additional BOM items within components ([#50](https://github.com/wireviz/WireViz/issues/50), [#115](https://github.com/wireviz/WireViz/pull/115)) +- Add support for length units in cables and wires ([#7](https://github.com/wireviz/WireViz/issues/7), [#196](https://github.com/wireviz/WireViz/pull/196) (with work from [#161](https://github.com/wireviz/WireViz/pull/161), [#162](https://github.com/wireviz/WireViz/pull/162), [#171](https://github.com/wireviz/WireViz/pull/171)), [#198](https://github.com/wireviz/WireViz/pull/198), [#205](https://github.com/wireviz/WireViz/issues/205). [#206](https://github.com/wireviz/WireViz/pull/206)) +- Add option to define connector pin colors ([#53](https://github.com/wireviz/WireViz/issues/53), [#141](https://github.com/wireviz/WireViz/pull/141)) +- Remove HTML links from the input attributes ([#164](https://github.com/wireviz/WireViz/pull/164)) +- Add harness metadata section ([#158](https://github.com/wireviz/WireViz/issues/158), [#214](https://github.com/wireviz/WireViz/pull/214)) +- Add support for supplier and supplier part number information ([#240](https://github.com/wireviz/WireViz/issues/240), [#241](https://github.com/wireviz/WireViz/pull/241/)) +- Add graph rendering options (background colors, fontname, color name display style, ...) ([#158](https://github.com/wireviz/WireViz/issues/158), [#214](https://github.com/wireviz/WireViz/pull/214)) +- Add support for background colors for cables and connectors, as well as for some individual cells ([#210](https://github.com/wireviz/WireViz/issues/210), [#219](https://github.com/wireviz/WireViz/pull/219)) +- Add optional tweaking of the .gv output ([#215](https://github.com/wireviz/WireViz/pull/215)) (experimental) ### Misc. fixes -- Remove case-sensitivity issues with pin names and labels ([#160](https://github.com/formatc1702/WireViz/issues/160), [#229](https://github.com/formatc1702/WireViz/pull/229)) -- Improve type hinting ([#156](https://github.com/formatc1702/WireViz/issues/156), [#163](https://github.com/formatc1702/WireViz/pull/163)) -- Move BOM management and HTML functions to separate modules ([#151](https://github.com/formatc1702/WireViz/issues/151), [#192](https://github.com/formatc1702/WireViz/pull/192)) -- Simplify BOM code ([#197](https://github.com/formatc1702/WireViz/pull/197)) -- Bug fixes ([#218](https://github.com/formatc1702/WireViz/pull/218), [#221](https://github.com/formatc1702/WireViz/pull/221)) +- Remove case-sensitivity issues with pin names and labels ([#160](https://github.com/wireviz/WireViz/issues/160), [#229](https://github.com/wireviz/WireViz/pull/229)) +- Improve type hinting ([#156](https://github.com/wireviz/WireViz/issues/156), [#163](https://github.com/wireviz/WireViz/pull/163)) +- Move BOM management and HTML functions to separate modules ([#151](https://github.com/wireviz/WireViz/issues/151), [#192](https://github.com/wireviz/WireViz/pull/192)) +- Simplify BOM code ([#197](https://github.com/wireviz/WireViz/pull/197)) +- Bug fixes ([#218](https://github.com/wireviz/WireViz/pull/218), [#221](https://github.com/wireviz/WireViz/pull/221)) ### Known issues -- Including images in the harness may lead to issues in the following cases: ([#189](https://github.com/formatc1702/WireViz/pull/189), [#220](https://github.com/formatc1702/WireViz/issues/220)) +- Including images in the harness may lead to issues in the following cases: ([#189](https://github.com/wireviz/WireViz/pull/189), [#220](https://github.com/wireviz/WireViz/issues/220)) - When using the `-o`/`--output_file` CLI option, specifying an output path in a different directory from the input file - When using the `--prepend-file` CLI option, specifying a prepend file in a different directory from the mail input file -## [0.2](https://github.com/formatc1702/WireViz/tree/v0.2) (2020-10-17) +## [0.2](https://github.com/wireviz/WireViz/tree/v0.2) (2020-10-17) ### Backward incompatible changes -- Change names of connector attributes ([#77](https://github.com/formatc1702/WireViz/issues/77), [#105](https://github.com/formatc1702/WireViz/pull/105)) +- Change names of connector attributes ([#77](https://github.com/wireviz/WireViz/issues/77), [#105](https://github.com/wireviz/WireViz/pull/105)) - `pinnumbers` is now `pins` - `pinout` is now `pinlabels` -- Remove ferrules as a separate connector type ([#78](https://github.com/formatc1702/WireViz/issues/78), [#102](https://github.com/formatc1702/WireViz/pull/102)) +- Remove ferrules as a separate connector type ([#78](https://github.com/wireviz/WireViz/issues/78), [#102](https://github.com/wireviz/WireViz/pull/102)) - Simple connectors like ferrules are now defined using the `style: simple` attribute -- Change the way loops are defined ([#79](https://github.com/formatc1702/WireViz/issues/79), [#75](https://github.com/formatc1702/WireViz/pull/75)) +- Change the way loops are defined ([#79](https://github.com/wireviz/WireViz/issues/79), [#75](https://github.com/wireviz/WireViz/pull/75)) - Wires looping between two pins of the same connector are now handled via the connector's `loops` attribute. See the [syntax description](syntax.md) for details. @@ -86,30 +86,30 @@ See the [syntax description](syntax.md) for details. ### New features -- Add bidirectional AWG/mm2 conversion ([#40](https://github.com/formatc1702/WireViz/issues/40), [#41](https://github.com/formatc1702/WireViz/pull/41)) -- Add support for part numbers ([#11](https://github.com/formatc1702/WireViz/pull/11), [#114](https://github.com/formatc1702/WireViz/issues/114), [#121](https://github.com/formatc1702/WireViz/pull/121)) -- Add support for multicolored wires ([#12](https://github.com/formatc1702/WireViz/issues/12), [#17](https://github.com/formatc1702/WireViz/pull/17), [#96](https://github.com/formatc1702/WireViz/pull/96), [#131](https://github.com/formatc1702/WireViz/issues/131), [#132](https://github.com/formatc1702/WireViz/pull/132)) -- Add support for images ([#27](https://github.com/formatc1702/WireViz/issues/27), [#153](https://github.com/formatc1702/WireViz/pull/153)) -- Add ability to export data directly to other programs ([#55](https://github.com/formatc1702/WireViz/pull/55)) -- Add support for line breaks in various fields ([#49](https://github.com/formatc1702/WireViz/issues/49), [#64](https://github.com/formatc1702/WireViz/pull/64)) -- Allow using connector pin names to define connections ([#72](https://github.com/formatc1702/WireViz/issues/72), [#139](https://github.com/formatc1702/WireViz/issues/139), [#140](https://github.com/formatc1702/WireViz/pull/140)) -- Make defining connection sets easier and more flexible ([#67](https://github.com/formatc1702/WireViz/issues/67), [#75](https://github.com/formatc1702/WireViz/pull/75)) -- Add new command line options ([#167](https://github.com/formatc1702/WireViz/issues/167), [#173](https://github.com/formatc1702/WireViz/pull/173)) -- Add new features to `build_examples.py` ([#118](https://github.com/formatc1702/WireViz/pull/118)) -- Add new colors ([#103](https://github.com/formatc1702/WireViz/pull/103), [#113](https://github.com/formatc1702/WireViz/pull/113), [#144](https://github.com/formatc1702/WireViz/issues/144), [#145](https://github.com/formatc1702/WireViz/pull/145)) -- Improve documentation ([#107](https://github.com/formatc1702/WireViz/issues/107), [#111](https://github.com/formatc1702/WireViz/pull/111)) +- Add bidirectional AWG/mm2 conversion ([#40](https://github.com/wireviz/WireViz/issues/40), [#41](https://github.com/wireviz/WireViz/pull/41)) +- Add support for part numbers ([#11](https://github.com/wireviz/WireViz/pull/11), [#114](https://github.com/wireviz/WireViz/issues/114), [#121](https://github.com/wireviz/WireViz/pull/121)) +- Add support for multicolored wires ([#12](https://github.com/wireviz/WireViz/issues/12), [#17](https://github.com/wireviz/WireViz/pull/17), [#96](https://github.com/wireviz/WireViz/pull/96), [#131](https://github.com/wireviz/WireViz/issues/131), [#132](https://github.com/wireviz/WireViz/pull/132)) +- Add support for images ([#27](https://github.com/wireviz/WireViz/issues/27), [#153](https://github.com/wireviz/WireViz/pull/153)) +- Add ability to export data directly to other programs ([#55](https://github.com/wireviz/WireViz/pull/55)) +- Add support for line breaks in various fields ([#49](https://github.com/wireviz/WireViz/issues/49), [#64](https://github.com/wireviz/WireViz/pull/64)) +- Allow using connector pin names to define connections ([#72](https://github.com/wireviz/WireViz/issues/72), [#139](https://github.com/wireviz/WireViz/issues/139), [#140](https://github.com/wireviz/WireViz/pull/140)) +- Make defining connection sets easier and more flexible ([#67](https://github.com/wireviz/WireViz/issues/67), [#75](https://github.com/wireviz/WireViz/pull/75)) +- Add new command line options ([#167](https://github.com/wireviz/WireViz/issues/167), [#173](https://github.com/wireviz/WireViz/pull/173)) +- Add new features to `build_examples.py` ([#118](https://github.com/wireviz/WireViz/pull/118)) +- Add new colors ([#103](https://github.com/wireviz/WireViz/pull/103), [#113](https://github.com/wireviz/WireViz/pull/113), [#144](https://github.com/wireviz/WireViz/issues/144), [#145](https://github.com/wireviz/WireViz/pull/145)) +- Improve documentation ([#107](https://github.com/wireviz/WireViz/issues/107), [#111](https://github.com/wireviz/WireViz/pull/111)) ### Misc. fixes - Improve BOM generation - Add various input sanity checks -- Improve HTML output ([#66](https://github.com/formatc1702/WireViz/issues/66), [#136](https://github.com/formatc1702/WireViz/pull/136), [#95](https://github.com/formatc1702/WireViz/pull/95), [#177](https://github.com/formatc1702/WireViz/pull/177)) -- Fix node rendering bug ([#69](https://github.com/formatc1702/WireViz/issues/69), [#104](https://github.com/formatc1702/WireViz/pull/104)) -- Improve shield rendering ([#125](https://github.com/formatc1702/WireViz/issues/125), [#126](https://github.com/formatc1702/WireViz/pull/126)) -- Add GitHub Linguist overrides ([#146](https://github.com/formatc1702/WireViz/issues/146), [#154](https://github.com/formatc1702/WireViz/pull/154)) +- Improve HTML output ([#66](https://github.com/wireviz/WireViz/issues/66), [#136](https://github.com/wireviz/WireViz/pull/136), [#95](https://github.com/wireviz/WireViz/pull/95), [#177](https://github.com/wireviz/WireViz/pull/177)) +- Fix node rendering bug ([#69](https://github.com/wireviz/WireViz/issues/69), [#104](https://github.com/wireviz/WireViz/pull/104)) +- Improve shield rendering ([#125](https://github.com/wireviz/WireViz/issues/125), [#126](https://github.com/wireviz/WireViz/pull/126)) +- Add GitHub Linguist overrides ([#146](https://github.com/wireviz/WireViz/issues/146), [#154](https://github.com/wireviz/WireViz/pull/154)) -## [0.1](https://github.com/formatc1702/WireViz/tree/v0.1) (2020-06-29) +## [0.1](https://github.com/wireviz/WireViz/tree/v0.1) (2020-06-29) - Initial release diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 09c9e061..beeb034c 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contribution Guidelines -When contributing to this repository, please [submit a new issue](https://github.com/formatc1702/WireViz/issues) first to discuss the proposed change, before submitting a pull request. +When contributing to this repository, please [submit a new issue](https://github.com/wireviz/WireViz/issues) first to discuss the proposed change, before submitting a pull request. ## Submitting a new Issue @@ -27,7 +27,7 @@ When contributing to this repository, please [submit a new issue](https://github 1. Push the changes to your fork. 1. Please format your code using [`isort`](https://pycqa.github.io/isort/) and [`black`](https://black.readthedocs.io) before submitting. 1. Submit a new pull request, using `dev` as the base branch. - - If your code changes or extends the WireViz YAML syntax, be sure to update the [syntax description document](https://github.com/formatc1702/WireViz/blob/dev/docs/syntax.md) in your PR. + - If your code changes or extends the WireViz YAML syntax, be sure to update the [syntax description document](https://github.com/wireviz/WireViz/blob/dev/docs/syntax.md) in your PR. 1. Please include in the PR description (and optionally also in the commit message body) a reference (# followed by issue number) to the issue where the suggested changes are discussed. ### Hints diff --git a/docs/buildscript.md b/docs/buildscript.md index 2655770e..35523d4f 100644 --- a/docs/buildscript.md +++ b/docs/buildscript.md @@ -2,7 +2,7 @@ diff --git a/src/wireviz/__init__.py b/src/wireviz/__init__.py index 7b328c85..76efc96a 100644 --- a/src/wireviz/__init__.py +++ b/src/wireviz/__init__.py @@ -5,4 +5,4 @@ CMD_NAME = "wireviz" # Lower case command and module name APP_NAME = "WireViz" # Application name in texts meant to be human readable -APP_URL = "https://github.com/formatc1702/WireViz" +APP_URL = "https://github.com/wireviz/WireViz" From f474cddedb60d0e7572894847191abe66d237f05 Mon Sep 17 00:00:00 2001 From: KV Date: Sun, 26 May 2024 17:28:09 +0200 Subject: [PATCH 09/36] Add HTML template placeholders for filename (#371) This will e.g. enable users to replace the SVG diagram with PNG, that is needed as a work-around when the SVG output from Graphviz is not looking good. Suggested as work-around for Graphviz bug in https://github.com/wireviz/WireViz/issues/175#issuecomment-2132206026 --- src/wireviz/wv_html.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 763da9d7..6fde7cdd 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -81,6 +81,9 @@ def generate_html_output( "": options.fontname, "": wv_colors.translate_color(options.bgcolor, "hex"), "": svgdata, + # TODO: "": base64 of png file + "": str(filename), + "": Path(filename).stem, "": bom_html, "": bom_html_reversed, "": "1", # TODO: handle multi-page documents From ea26116c8108463cdb3b9d1cef1d08cc6d5e1948 Mon Sep 17 00:00:00 2001 From: KV Date: Fri, 31 May 2024 22:24:45 +0200 Subject: [PATCH 10/36] Add HTML template placeholder for diagram_png_base64 (#371) This will enable users to replace the SVG diagram with an embedded PNG, that is an improved work-around when the SVG output from Graphviz is not looking good. Suggested as work-around for Graphviz bug in https://github.com/wireviz/WireViz/issues/175#issuecomment-2132206026 --- src/wireviz/svgembed.py | 14 ++++++++++++++ src/wireviz/wv_html.py | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/wireviz/svgembed.py b/src/wireviz/svgembed.py index ab6b9f1e..c8d637c8 100644 --- a/src/wireviz/svgembed.py +++ b/src/wireviz/svgembed.py @@ -8,6 +8,20 @@ mime_subtype_replacements = {"jpg": "jpeg", "tif": "tiff"} +# TODO: Share cache and code between data_URI_base64() and embed_svg_images() +def data_URI_base64(file: Union[str, Path], media: str = "image") -> str: + """Return Base64-encoded data URI of input file.""" + file = Path(file) + b64 = base64.b64encode(file.read_bytes()).decode("utf-8") + uri = f"data:{media}/{get_mime_subtype(file)};base64, {b64}" + # print(f"data_URI_base64('{file}', '{media}') -> {len(uri)}-character URI") + if len(uri) > 65535: + print( + "data_URI_base64(): Warning: Browsers might have different URI length limitations" + ) + return uri + + def embed_svg_images(svg_in: str, base_path: Union[str, Path] = Path.cwd()) -> str: images_b64 = {} # cache of base64-encoded images diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 6fde7cdd..e939c6f2 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -6,6 +6,7 @@ from wireviz import APP_NAME, APP_URL, __version__, wv_colors from wireviz.DataClasses import Metadata, Options +from wireviz.svgembed import data_URI_base64 from wireviz.wv_gv_html import html_line_breaks from wireviz.wv_helper import ( flatten2d, @@ -81,7 +82,7 @@ def generate_html_output( "": options.fontname, "": wv_colors.translate_color(options.bgcolor, "hex"), "": svgdata, - # TODO: "": base64 of png file + "": data_URI_base64(f"{filename}.png"), "": str(filename), "": Path(filename).stem, "": bom_html, From 70a33edca55834be225863a4689476606f406373 Mon Sep 17 00:00:00 2001 From: KV Date: Fri, 31 May 2024 23:03:42 +0200 Subject: [PATCH 11/36] Avoid reading diagram file to embed unless used (#371) Add local replacement_if_used() that call function to read the file only when needed and append the return value as replacement. --- src/wireviz/wv_html.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index e939c6f2..176d2303 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -2,7 +2,7 @@ import re from pathlib import Path -from typing import Dict, List, Union +from typing import Callable, Dict, List, Union from wireviz import APP_NAME, APP_URL, __version__, wv_colors from wireviz.DataClasses import Metadata, Options @@ -37,12 +37,12 @@ def generate_html_output( html = open_file_read(templatefile).read() - # embed SVG diagram - with open_file_read(f"{filename}.tmp.svg") as file: - svgdata = re.sub( + # embed SVG diagram (only if used) + def svgdata() -> str: + return re.sub( "^<[?]xml [^?>]*[?]>[^<]*]*>", "", - file.read(), + open_file_read(f"{filename}.tmp.svg").read(), 1, ) @@ -81,8 +81,6 @@ def generate_html_output( "": f"{APP_NAME} {__version__} - {APP_URL}", "": options.fontname, "": wv_colors.translate_color(options.bgcolor, "hex"), - "": svgdata, - "": data_URI_base64(f"{filename}.png"), "": str(filename), "": Path(filename).stem, "": bom_html, @@ -91,6 +89,16 @@ def generate_html_output( "": "1", # TODO: handle multi-page documents } + def replacement_if_used(key: str, func: Callable[[], str]) -> None: + """Append replacement only if used in html.""" + if key in html: + replacements[key] = func() + + replacement_if_used("", svgdata) + replacement_if_used( + "", lambda: data_URI_base64(f"{filename}.png") + ) + # prepare metadata replacements if metadata: for item, contents in metadata.items(): From fc7ea088b43d0d3f73a0ae64edf76248d273c9a8 Mon Sep 17 00:00:00 2001 From: KV Date: Wed, 5 Jun 2024 21:56:42 +0200 Subject: [PATCH 12/36] Add HTML output templates README.md (#371) Describe the HTML Output Templates, how they are specified, and placeholder usage within these templates. --- src/wireviz/templates/README.md | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/wireviz/templates/README.md diff --git a/src/wireviz/templates/README.md b/src/wireviz/templates/README.md new file mode 100644 index 00000000..41f9e0ac --- /dev/null +++ b/src/wireviz/templates/README.md @@ -0,0 +1,51 @@ +# HTML Output Templates + +This is the standard folder where WireViz looks for an HTML output template file. + +## Which HTML Output Template File is Used? + +A named HTML output template can optionally be specified as +`metadata.template.name` in the YAML input: +```yaml +metadata: + template: + name: din-6771 +``` +In the case above, WireViz will search for a template file named +`din-6771.html` in these folders: +1. In the same folder as the YAML input file. +2. In this standard template folder. + +If no HTML output template is specified, the `simple` template is assumed +(i.e. filename `simple.html`, and in this case, +only the standard template folder is searched). + +## Placeholders in HTML Output Templates + +HTML output template files might contain placeholders that will be replaced by +generated text by WireViz when producing HTML output based on such a template. +A placeholder starts with ``. +Note that there must be one single space between `--` and `%` at both ends. + +| Placeholder | Replaced by | +| --- | --- | +| `` | The application name, version, and URL | +| `` | The value of `options.fontname` | +| `` | The HEX color translation of `options.bgcolor` | +| `` | The output path and filename without extension | +| `` | The output filename without path nor extension | +| `` | BOM as HTML table with headers at top | +| `` | Reversed BOM as HTML table with headers at bottom | +| `` | `1` (multi-page documents not yet supported) | +| `` | `1` (multi-page documents not yet supported) | +| `` | Embedded SVG diagram as valid HTML | +| `` | Embedded base64 encoded PNG diagram as URI | +| `` | String or numeric value of `metadata.{item}` | +| `` | Category number `{i}` within dict value of `metadata.{item}` | +| `` | Value of `metadata.{item}.{category}.{key}` | + +Note that `{item}`, `{category}` and `{key}` in the description above can be +any valid YAML key, and `{i}` is an integer representing the 1-based index of +category entries in a dict `metadata.{item}` entry. +The `{` and `}` characters are not literally part of the syntax, just used in +this documentation to enclose the variable parts of the keywords. From 6ba33fb5dc21f152e606e2c520ebbab0e50a1390 Mon Sep 17 00:00:00 2001 From: KV Date: Wed, 5 Jun 2024 22:21:40 +0200 Subject: [PATCH 13/36] Rename diagram_png_base64 to diagram_png_b64 (#371) --- src/wireviz/templates/README.md | 8 ++++---- src/wireviz/wv_html.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wireviz/templates/README.md b/src/wireviz/templates/README.md index 41f9e0ac..a172aa4a 100644 --- a/src/wireviz/templates/README.md +++ b/src/wireviz/templates/README.md @@ -39,10 +39,10 @@ Note that there must be one single space between `--` and `%` at both ends. | `` | `1` (multi-page documents not yet supported) | | `` | `1` (multi-page documents not yet supported) | | `` | Embedded SVG diagram as valid HTML | -| `` | Embedded base64 encoded PNG diagram as URI | -| `` | String or numeric value of `metadata.{item}` | -| `` | Category number `{i}` within dict value of `metadata.{item}` | -| `` | Value of `metadata.{item}.{category}.{key}` | +| `` | Embedded base64 encoded PNG diagram as URI | +| `` | String or numeric value of `metadata.{item}` | +| `` | Category number `{i}` within dict value of `metadata.{item}` | +| `` | Value of `metadata.{item}.{category}.{key}` | Note that `{item}`, `{category}` and `{key}` in the description above can be any valid YAML key, and `{i}` is an integer representing the 1-based index of diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 176d2303..4941e94a 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -96,7 +96,7 @@ def replacement_if_used(key: str, func: Callable[[], str]) -> None: replacement_if_used("", svgdata) replacement_if_used( - "", lambda: data_URI_base64(f"{filename}.png") + "", lambda: data_URI_base64(f"{filename}.png") ) # prepare metadata replacements From 177eb9e387f694c8710ea5cfb9f1b3712d41607d Mon Sep 17 00:00:00 2001 From: KV Date: Mon, 10 Jun 2024 00:05:19 +0200 Subject: [PATCH 14/36] Add link from syntax.md to HTML output templates (#371) --- docs/syntax.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/syntax.md b/docs/syntax.md index de672847..265427d2 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -353,6 +353,7 @@ If any component is defined in the `connectors` or `cables` sections but not ref # If no value is specified for 'title', then the # output filename without extension is used. ``` +See [HTML Output Templates](../src/wireviz/templates/) for how metadata entries can be inserted into the HTML output. ## Options From 668ba72975c1420cf28d759616399e372b2ec424 Mon Sep 17 00:00:00 2001 From: KV Date: Sun, 2 Jun 2024 20:26:07 +0200 Subject: [PATCH 15/36] Avoid decimal point and trailing zero for integer BOM quantities (#374) Fixes #340 --- src/wireviz/wv_bom.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wireviz/wv_bom.py b/src/wireviz/wv_bom.py index 27ee59b0..7eecfdf7 100644 --- a/src/wireviz/wv_bom.py +++ b/src/wireviz/wv_bom.py @@ -204,7 +204,9 @@ def generate_bom(harness: "Harness") -> List[BOMEntry]: bom.append( { **group_entries[0], - "qty": round(total_qty, 3), + "qty": int(total_qty) + if float(total_qty).is_integer() + else round(total_qty, 3), "designators": sorted(set(designators)), } ) From 6488eb582b052fb58bb7f644662d4e4919c1ed32 Mon Sep 17 00:00:00 2001 From: KV Date: Wed, 5 Jun 2024 17:59:41 +0200 Subject: [PATCH 16/36] Avoid Graphviz error when hiding all pins (#375) Fixes #257 --- src/wireviz/Harness.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index fb56c8a5..34df9a2e 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -253,6 +253,9 @@ def create_graph(self) -> Graph: pinhtml.append(" ") + if len(pinhtml) == 2: # Table start and end with no rows between? + pinhtml = [""] # Avoid Graphviz error + html = [ row.replace("", "\n".join(pinhtml)) for row in html From 088c6038c71561fab87ea7bbb8e2f926c2cacf93 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Fri, 7 Jun 2024 17:03:32 +0200 Subject: [PATCH 17/36] Add documentation on template separator character --- docs/syntax.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/syntax.md b/docs/syntax.md index 265427d2..2c92fd34 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -319,6 +319,8 @@ connections: Since the internally assigned designator of an unnamed component is not known to the user, one instance of the connector can not be referenced again outside the point of creation (i.e. in other connection sets, or later in the same set). Autogeneration of unnamed instances is therefore only useful for terminals with only one wire attached, or splices with exactly one wire going in, and one wire going out. If a component is to be used in other connection sets (e.g. for a three-way splice, or a crimp where multiple wires are joined), a named instance needs to be used. +The default character to trigger autogeneration of components is `.`. A different character can be specified using the `template_separator` option (see below). + Names of autogenerated components are hidden by default. While they can be shown in the graphical output using the `show_name: true` option, it is not recommended to manually use the internally assigned designator (starting with a double underscore `__`), since it might change in future WireViz versions, or when the order of items in connection sets changes. @@ -388,6 +390,9 @@ See [HTML Output Templates](../src/wireviz/templates/) for how metadata entries # about additional components inside the diagram node (connector/cable box). # If False, show all info about additional components inside the diagram node. mini_bom_mode: # Default = True + + # Character to split template and designator for autogenerated components + template_separator: # Default = '.' ``` From eed00e13222039ba905573b5ab95964d77afa31c Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Fri, 7 Jun 2024 17:21:56 +0200 Subject: [PATCH 18/36] Add changelog for v0.4.1 (WIP) --- docs/CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1ce418ca..8f9345a9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## [0.4.1] (2024-XX-XX) + +### Bugfixes + +- Use correct default title ([#360](https://github.com/wireviz/WireViz/issues/360), [#361](https://github.com/wireviz/WireViz/pull/361)) +- Update project URL references ([#364](https://github.com/wireviz/WireViz/pull/364)) +- Include missing files in published package ([#345](https://github.com/wireviz/WireViz/issues/345), [#347](https://github.com/wireviz/WireViz/pull/347)) +- TODO 344 346 355 358 + + + ## [0.4](https://github.com/wireviz/WireViz/tree/v0.4) (2024-05-12) ### Backward-incompatible changes From 795f3321a330668e34ea63599f6665aa53da268d Mon Sep 17 00:00:00 2001 From: KV Date: Sat, 8 Jun 2024 01:49:35 +0200 Subject: [PATCH 19/36] Update changelog (WIP) --- docs/CHANGELOG.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8f9345a9..72d74d2d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,13 +2,22 @@ ## [0.4.1] (2024-XX-XX) +### Improvements to help reported issues +- Improved error message for strange YAML input TODO (342 383) +- TODO (377 380) +- TODO (175 371) + ### Bugfixes -- Use correct default title ([#360](https://github.com/wireviz/WireViz/issues/360), [#361](https://github.com/wireviz/WireViz/pull/361)) +- TODO (377 381) +- TODO (257 375) +- Avoid decimal point and trailing zero for integer BOM quantities ([#340](https://github.com/wireviz/WireViz/issues/340), [#374](https://github.com/wireviz/WireViz/pull/374)) - Update project URL references ([#364](https://github.com/wireviz/WireViz/pull/364)) +- Add missing import of embed_svg_images ([#363](https://github.com/wireviz/WireViz/pull/363)) +- Use correct default title ([#360](https://github.com/wireviz/WireViz/issues/360), [#361](https://github.com/wireviz/WireViz/pull/361)) +- TODO (355 358) - Include missing files in published package ([#345](https://github.com/wireviz/WireViz/issues/345), [#347](https://github.com/wireviz/WireViz/pull/347)) -- TODO 344 346 355 358 - +- Handle OSError [errno.EINVAL] ([#344](https://github.com/wireviz/WireViz/issues/344), [#346](https://github.com/wireviz/WireViz/pull/346)) ## [0.4](https://github.com/wireviz/WireViz/tree/v0.4) (2024-05-12) From c997bfe19baa7067b43e1ec590568c86b213ddbb Mon Sep 17 00:00:00 2001 From: KV Date: Sun, 9 Jun 2024 22:34:37 +0200 Subject: [PATCH 20/36] Rename "sheetsize_default" to (#380) Fixes #377 (makes HTML output template placeholders more consistent) --- src/wireviz/templates/README.md | 1 + src/wireviz/templates/din-6771.html | 2 +- src/wireviz/wv_html.py | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/wireviz/templates/README.md b/src/wireviz/templates/README.md index a172aa4a..31d3ef88 100644 --- a/src/wireviz/templates/README.md +++ b/src/wireviz/templates/README.md @@ -43,6 +43,7 @@ Note that there must be one single space between `--` and `%` at both ends. | `` | String or numeric value of `metadata.{item}` | | `` | Category number `{i}` within dict value of `metadata.{item}` | | `` | Value of `metadata.{item}.{category}.{key}` | +| `` | Value of `metadata.template.sheetsize` | Note that `{item}`, `{category}` and `{key}` in the description above can be any valid YAML key, and `{i}` is an integer representing the 1-based index of diff --git a/src/wireviz/templates/din-6771.html b/src/wireviz/templates/din-6771.html index 547a340c..1aab000d 100644 --- a/src/wireviz/templates/din-6771.html +++ b/src/wireviz/templates/din-6771.html @@ -179,7 +179,7 @@
-
+
diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 4941e94a..4052fdcf 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -87,6 +87,9 @@ def svgdata() -> str: "": bom_html_reversed, "": "1", # TODO: handle multi-page documents "": "1", # TODO: handle multi-page documents + "": metadata.get("template", {}).get( + "sheetsize", "" + ), } def replacement_if_used(key: str, func: Callable[[], str]) -> None: @@ -112,11 +115,8 @@ def replacement_if_used(key: str, func: Callable[[], str]) -> None: replacements[f""] = ( html_line_breaks(str(entry_value)) ) - - replacements['"sheetsize_default"'] = '"{}"'.format( - metadata.get("template", {}).get("sheetsize", "") - ) - # include quotes so no replacement happens within