Merge branch 'master' into ferdnyc-issue-templates

This commit is contained in:
Frank Dana 2025-05-16 10:36:43 -04:00 committed by GitHub
commit eb847698d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
67 changed files with 382 additions and 252 deletions

View File

@ -4,29 +4,40 @@ on: [push, pull_request, workflow_dispatch]
jobs: jobs:
build: build:
runs-on: ubuntu-latest
strategy: strategy:
max-parallel: 4 max-parallel: 6
matrix: matrix:
python-version: [3.7, 3.8] # ubuntu-22.04 supports Python 3.7-3.12
# ubuntu-24.04 (currently latest & preferred) supports Python 3.9-3.12
# More details: https://github.com/actions/runner-images/issues/10636
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
include:
- os: ubuntu-22.04
python-version: "3.7"
- os: ubuntu-22.04
python-version: "3.8"
runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2 uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Setup Graphviz - name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1 uses: ts-graphviz/setup-graphviz@v2
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install . pip install .
- name: Create Examples - name: Create Examples
run: PYTHONPATH=$(pwd)/src:$PYTHONPATH cd src/wireviz/ && python build_examples.py run: PYTHONPATH=$(pwd)/src/wireviz:$PYTHONPATH cd src/wireviz/ && python build_examples.py
- name: Upload examples, demos, and tutorials - name: Upload examples, demos, and tutorials
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v4
with: with:
name: examples-and-tutorials name: examples-and-tutorials-v${{ matrix.python-version }}
path: | path: |
examples/ examples/
tutorial/ tutorial/
if-no-files-found: error

View File

@ -1,6 +1,31 @@
# Change Log # Change Log
## [0.4](https://github.com/formatc1702/WireViz/tree/v0.4) (2024-05-12) ## [0.4.1] (2024-07-13)
### Improvements to help reported issues
- Print Python & OS versions when raising unexpected OSError related to #346 & #392 (bugfixes below)
- Explain unexpeced top-level type ([#342](https://github.com/wireviz/WireViz/issues/342), [#383](https://github.com/wireviz/WireViz/pull/383))
- Add non-empty label to reduce over-sized loops ([#286](https://github.com/wireviz/WireViz/issues/286), [#381](https://github.com/wireviz/WireViz/pull/381))
- Improve placeholder name consistency ([#377](https://github.com/wireviz/WireViz/issues/377), [#380](https://github.com/wireviz/WireViz/pull/380))
- Add work-around for Graphviz SVG bug ([#175](https://github.com/wireviz/WireViz/issues/175), [#371](https://github.com/wireviz/WireViz/pull/371))
### Bugfixes
- Avoid ResourceWarning: unclosed file ([#309 (comment)](https://github.com/wireviz/WireViz/pull/309#issuecomment-2170988381), [#395](https://github.com/wireviz/WireViz/pull/395))
- Catch ValueError and OSError(errno=None) ([#318 (review)](https://github.com/wireviz/WireViz/pull/318#pullrequestreview-1457016602), [#391](https://github.com/wireviz/WireViz/issues/391), [#392](https://github.com/wireviz/WireViz/pull/392))
- Add minor missing doc entry ([#186 (comment)](https://github.com/wireviz/WireViz/pull/186#issuecomment-2139037434), [#186 (comment)](https://github.com/wireviz/WireViz/pull/186#issuecomment-2155032522))
- Avoid Graphviz error when hiding all pins ([#257](https://github.com/wireviz/WireViz/issues/257), [#375](https://github.com/wireviz/WireViz/pull/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 ([#316 (comment)](https://github.com/wireviz/WireViz/issues/316#issuecomment-1568748914), [#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))
- Fix bugs in mate processing ([#355](https://github.com/wireviz/WireViz/issues/355), [#358](https://github.com/wireviz/WireViz/pull/358))
- Include missing files in published package ([#345](https://github.com/wireviz/WireViz/issues/345), [#347](https://github.com/wireviz/WireViz/pull/347))
- Catch 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)
### Backward-incompatible changes ### Backward-incompatible changes
- New syntax for autogenerated components ([#184](https://github.com/wireviz/WireViz/issues/184), [#186](https://github.com/wireviz/WireViz/pull/186)) - New syntax for autogenerated components ([#184](https://github.com/wireviz/WireViz/issues/184), [#186](https://github.com/wireviz/WireViz/pull/186))
@ -9,7 +34,6 @@
- The path specified with the `-o`/`--output-dir` option no longer includes the filename (without extension) of the generated files. Use the `-O`/`--output-name` option to specify a different filename for the generated files. - The path specified with the `-o`/`--output-dir` option no longer includes the filename (without extension) of the generated files. Use the `-O`/`--output-name` option to specify a different filename for the generated files.
- The `.gv` file is no longer included as a default output format (only as an intermediate file during processing) unless specified with the new `-f` option described below. - The `.gv` file is no longer included as a default output format (only as an intermediate file during processing) unless specified with the new `-f` option described below.
### New features ### New features
- Allow mates between connectors ([#134](https://github.com/wireviz/WireViz/issues/134), [#186](https://github.com/wireviz/WireViz/pull/186)) - Allow mates between connectors ([#134](https://github.com/wireviz/WireViz/issues/134), [#186](https://github.com/wireviz/WireViz/pull/186))
@ -25,91 +49,89 @@
- Minor adjustments ([#256](https://github.com/wireviz/WireViz/pull/256)) - 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 ### 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 ### 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 ### 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 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/formatc1702/WireViz/issues/50), [#115](https://github.com/formatc1702/WireViz/pull/115)) - 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/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 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/formatc1702/WireViz/issues/53), [#141](https://github.com/formatc1702/WireViz/pull/141)) - 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/formatc1702/WireViz/pull/164)) - Remove HTML links from the input attributes ([#164](https://github.com/wireviz/WireViz/pull/164))
- Add harness metadata section ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214)) - 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/formatc1702/WireViz/issues/240), [#241](https://github.com/formatc1702/WireViz/pull/241/)) - 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/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214)) - 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/formatc1702/WireViz/issues/210), [#219](https://github.com/formatc1702/WireViz/pull/219)) - 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/formatc1702/WireViz/pull/215)) (experimental) - Add optional tweaking of the .gv output ([#215](https://github.com/wireviz/WireViz/pull/215)) (experimental)
### Misc. fixes ### 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)) - 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/formatc1702/WireViz/issues/156), [#163](https://github.com/formatc1702/WireViz/pull/163)) - 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/formatc1702/WireViz/issues/151), [#192](https://github.com/formatc1702/WireViz/pull/192)) - 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/formatc1702/WireViz/pull/197)) - Simplify BOM code ([#197](https://github.com/wireviz/WireViz/pull/197))
- Bug fixes ([#218](https://github.com/formatc1702/WireViz/pull/218), [#221](https://github.com/formatc1702/WireViz/pull/221)) - Bug fixes ([#218](https://github.com/wireviz/WireViz/pull/218), [#221](https://github.com/wireviz/WireViz/pull/221))
### Known issues ### 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 `-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 - 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 ### 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` - `pinnumbers` is now `pins`
- `pinout` is now `pinlabels` - `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 - 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. - 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. See the [syntax description](syntax.md) for details.
### New features ### New features
- Add bidirectional AWG/mm2 conversion ([#40](https://github.com/formatc1702/WireViz/issues/40), [#41](https://github.com/formatc1702/WireViz/pull/41)) - 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/formatc1702/WireViz/pull/11), [#114](https://github.com/formatc1702/WireViz/issues/114), [#121](https://github.com/formatc1702/WireViz/pull/121)) - 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/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 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/formatc1702/WireViz/issues/27), [#153](https://github.com/formatc1702/WireViz/pull/153)) - 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/formatc1702/WireViz/pull/55)) - 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/formatc1702/WireViz/issues/49), [#64](https://github.com/formatc1702/WireViz/pull/64)) - 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/formatc1702/WireViz/issues/72), [#139](https://github.com/formatc1702/WireViz/issues/139), [#140](https://github.com/formatc1702/WireViz/pull/140)) - 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/formatc1702/WireViz/issues/67), [#75](https://github.com/formatc1702/WireViz/pull/75)) - 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/formatc1702/WireViz/issues/167), [#173](https://github.com/formatc1702/WireViz/pull/173)) - 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/formatc1702/WireViz/pull/118)) - Add new features to `build_examples.py` ([#118](https://github.com/wireviz/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)) - 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/formatc1702/WireViz/issues/107), [#111](https://github.com/formatc1702/WireViz/pull/111)) - Improve documentation ([#107](https://github.com/wireviz/WireViz/issues/107), [#111](https://github.com/wireviz/WireViz/pull/111))
### Misc. fixes ### Misc. fixes
- Improve BOM generation - Improve BOM generation
- Add various input sanity checks - 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)) - 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/formatc1702/WireViz/issues/69), [#104](https://github.com/formatc1702/WireViz/pull/104)) - 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/formatc1702/WireViz/issues/125), [#126](https://github.com/formatc1702/WireViz/pull/126)) - 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/formatc1702/WireViz/issues/146), [#154](https://github.com/formatc1702/WireViz/pull/154)) - 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 - Initial release

View File

@ -1,6 +1,6 @@
# Contribution Guidelines # 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 ## 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. 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. 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. 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. 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 ### Hints

View File

@ -2,7 +2,7 @@
<!-- <!--
The following text is taken from #118 The following text is taken from #118
https://github.com/formatc1702/WireViz/pull/118 https://github.com/wireviz/WireViz/pull/118
TODO: write a better explaination --> TODO: write a better explaination -->

View File

@ -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. 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. 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. 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.
@ -353,6 +355,7 @@ If any component is defined in the `connectors` or `cables` sections but not ref
# If no value is specified for 'title', then the # If no value is specified for 'title', then the
# output filename without extension is used. # 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 ## Options
@ -387,6 +390,9 @@ If any component is defined in the `connectors` or `cables` sections but not ref
# about additional components inside the diagram node (connector/cable box). # about additional components inside the diagram node (connector/cable box).
# If False, show all info about additional components inside the diagram node. # If False, show all info about additional components inside the diagram node.
mini_bom_mode: <bool> # Default = True mini_bom_mode: <bool> # Default = True
# Character to split template and designator for autogenerated components
template_separator: <str> # Default = '.'
``` ```

4
examples/demo01.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/demo01.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>demo01</title> <title>demo01</title>
<style> <style>

4
examples/demo02.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/demo02.html generated
View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>WireViz Demo 2</title> <title>WireViz Demo 2</title>
<style> <style>
body { body {

4
examples/ex01.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex01.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex01</title> <title>ex01</title>
<style> <style>

4
examples/ex02.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex02.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex02</title> <title>ex02</title>
<style> <style>

4
examples/ex03.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex03.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex03</title> <title>ex03</title>
<style> <style>

4
examples/ex04.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex04.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex04</title> <title>ex04</title>
<style> <style>

4
examples/ex05.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex05.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex05</title> <title>ex05</title>
<style> <style>

8
examples/ex06.bom.tsv generated
View File

@ -1,6 +1,6 @@
Id Description Qty Unit Designators Id Description Qty Unit Designators
1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6 1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6
2 Wire, 0.25 mm², PK 1.0 m W1, W2, W3, W4, W5 2 Wire, 0.25 mm², PK 1 m W1, W2, W3, W4, W5
3 Wire, 0.25 mm², TQ 1.0 m W1, W2, W3, W4, W5 3 Wire, 0.25 mm², TQ 1 m W1, W2, W3, W4, W5
4 Wire, 0.25 mm², VT 1.0 m W1, W2, W3, W4, W5 4 Wire, 0.25 mm², VT 1 m W1, W2, W3, W4, W5
5 Wire, 0.25 mm², YE 1.0 m W1, W2, W3, W4, W5 5 Wire, 0.25 mm², YE 1 m W1, W2, W3, W4, W5

1 Id Description Qty Unit Designators
2 1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6
3 2 Wire, 0.25 mm², PK 1.0 1 m W1, W2, W3, W4, W5
4 3 Wire, 0.25 mm², TQ 1.0 1 m W1, W2, W3, W4, W5
5 4 Wire, 0.25 mm², VT 1.0 1 m W1, W2, W3, W4, W5
6 5 Wire, 0.25 mm², YE 1.0 1 m W1, W2, W3, W4, W5

4
examples/ex06.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

10
examples/ex06.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex06</title> <title>ex06</title>
<style> <style>
@ -716,28 +716,28 @@
<tr> <tr>
<td class="bom_col_id">2</td> <td class="bom_col_id">2</td>
<td class="bom_col_description">Wire, 0.25 mm², PK</td> <td class="bom_col_description">Wire, 0.25 mm², PK</td>
<td class="bom_col_qty">1.0</td> <td class="bom_col_qty">1</td>
<td class="bom_col_unit">m</td> <td class="bom_col_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">3</td> <td class="bom_col_id">3</td>
<td class="bom_col_description">Wire, 0.25 mm², TQ</td> <td class="bom_col_description">Wire, 0.25 mm², TQ</td>
<td class="bom_col_qty">1.0</td> <td class="bom_col_qty">1</td>
<td class="bom_col_unit">m</td> <td class="bom_col_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">4</td> <td class="bom_col_id">4</td>
<td class="bom_col_description">Wire, 0.25 mm², VT</td> <td class="bom_col_description">Wire, 0.25 mm², VT</td>
<td class="bom_col_qty">1.0</td> <td class="bom_col_qty">1</td>
<td class="bom_col_unit">m</td> <td class="bom_col_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">5</td> <td class="bom_col_id">5</td>
<td class="bom_col_description">Wire, 0.25 mm², YE</td> <td class="bom_col_description">Wire, 0.25 mm², YE</td>
<td class="bom_col_qty">1.0</td> <td class="bom_col_qty">1</td>
<td class="bom_col_unit">m</td> <td class="bom_col_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>

4
examples/ex07.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex07.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex07</title> <title>ex07</title>
<style> <style>

4
examples/ex08.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex08.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex08</title> <title>ex08</title>
<style> <style>

4
examples/ex09.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex09.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex09</title> <title>ex09</title>
<style> <style>

4
examples/ex10.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex10.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex10</title> <title>ex10</title>
<style> <style>

4
examples/ex11.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex11.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex11</title> <title>ex11</title>
<style> <style>

4
examples/ex12.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex12.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex12</title> <title>ex12</title>
<style> <style>

4
examples/ex13.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex13.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex13</title> <title>ex13</title>
<style> <style>

4
examples/ex14.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex14.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>ex14</title> <title>ex14</title>
<style> <style>

View File

@ -27,6 +27,7 @@ setup(
keywords="cable connector hardware harness wiring wiring-diagram wiring-harness", keywords="cable connector hardware harness wiring wiring-diagram wiring-harness",
url=APP_URL, url=APP_URL,
package_dir={"": "src"}, package_dir={"": "src"},
package_data={CMD_NAME: ["templates/*.html"]},
packages=find_packages("src"), packages=find_packages("src"),
entry_points={ entry_points={
"console_scripts": [ "console_scripts": [

View File

@ -91,7 +91,6 @@ class Image:
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html # See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
def __post_init__(self): def __post_init__(self):
if self.fixedsize is None: if self.fixedsize is None:
# Default True if any dimension specified unless self.scale also is specified. # Default True if any dimension specified unless self.scale also is specified.
self.fixedsize = (self.width or self.height) and self.scale is None self.fixedsize = (self.width or self.height) and self.scale is None
@ -166,7 +165,6 @@ class Connector:
additional_components: List[AdditionalComponent] = field(default_factory=list) additional_components: List[AdditionalComponent] = field(default_factory=list)
def __post_init__(self) -> None: def __post_init__(self) -> None:
if isinstance(self.image, dict): if isinstance(self.image, dict):
self.image = Image(**self.image) self.image = Image(**self.image)
@ -276,7 +274,6 @@ class Cable:
additional_components: List[AdditionalComponent] = field(default_factory=list) additional_components: List[AdditionalComponent] = field(default_factory=list)
def __post_init__(self) -> None: def __post_init__(self) -> None:
if isinstance(self.image, dict): if isinstance(self.image, dict):
self.image = Image(**self.image) self.image = Image(**self.image)
@ -386,7 +383,6 @@ class Cable:
to_name: Optional[Designator], to_name: Optional[Designator],
to_pin: NoneOrMorePinIndices, to_pin: NoneOrMorePinIndices,
) -> None: ) -> None:
from_pin = int2tuple(from_pin) from_pin = int2tuple(from_pin)
via_wire = int2tuple(via_wire) via_wire = int2tuple(via_wire)
to_pin = int2tuple(to_pin) to_pin = int2tuple(to_pin)

View File

@ -8,7 +8,6 @@ from pathlib import Path
from typing import Any, List, Union from typing import Any, List, Union
from graphviz import Graph from graphviz import Graph
from wireviz import APP_NAME, APP_URL, __version__, wv_colors from wireviz import APP_NAME, APP_URL, __version__, wv_colors
from wireviz.DataClasses import ( from wireviz.DataClasses import (
Cable, Cable,
@ -17,10 +16,10 @@ from wireviz.DataClasses import (
MatePin, MatePin,
Metadata, Metadata,
Options, Options,
Tweak,
Side, Side,
Tweak,
) )
from wireviz.svgembed import embed_svg_images_file from wireviz.svgembed import embed_svg_images, embed_svg_images_file
from wireviz.wv_bom import ( from wireviz.wv_bom import (
HEADER_MPN, HEADER_MPN,
HEADER_PN, HEADER_PN,
@ -44,11 +43,10 @@ from wireviz.wv_gv_html import (
) )
from wireviz.wv_helper import ( from wireviz.wv_helper import (
awg_equiv, awg_equiv,
file_write_text,
flatten2d, flatten2d,
is_arrow, is_arrow,
mm2_equiv, mm2_equiv,
open_file_read,
open_file_write,
tuplelist2tsv, tuplelist2tsv,
) )
from wireviz.wv_html import generate_html_output from wireviz.wv_html import generate_html_output
@ -59,12 +57,14 @@ OLD_CONNECTOR_ATTR = {
"autogenerate": "is replaced with new syntax in v0.4", "autogenerate": "is replaced with new syntax in v0.4",
} }
def check_old(node: str, old_attr: dict, args: dict) -> None: def check_old(node: str, old_attr: dict, args: dict) -> None:
"""Raise exception for any outdated attributes in args.""" """Raise exception for any outdated attributes in args."""
for attr, descr in old_attr.items(): for attr, descr in old_attr.items():
if attr in args: if attr in args:
raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}") raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}")
@dataclass @dataclass
class Harness: class Harness:
metadata: Metadata metadata: Metadata
@ -172,7 +172,7 @@ class Harness:
bgcolor=wv_colors.translate_color(self.options.bgcolor, "HEX"), bgcolor=wv_colors.translate_color(self.options.bgcolor, "HEX"),
nodesep="0.33", nodesep="0.33",
fontname=self.options.fontname, fontname=self.options.fontname,
) ) # TODO: Add graph attribute: charset="utf-8",
dot.attr( dot.attr(
"node", "node",
shape="none", shape="none",
@ -186,7 +186,6 @@ class Harness:
dot.attr("edge", style="bold", fontname=self.options.fontname) dot.attr("edge", style="bold", fontname=self.options.fontname)
for connector in self.connectors.values(): for connector in self.connectors.values():
# If no wires connected (except maybe loop wires)? # If no wires connected (except maybe loop wires)?
if not (connector.ports_left or connector.ports_right): if not (connector.ports_left or connector.ports_right):
connector.ports_left = True # Use left side pins. connector.ports_left = True # Use left side pins.
@ -253,6 +252,9 @@ class Harness:
pinhtml.append(" </table>") pinhtml.append(" </table>")
if len(pinhtml) == 2: # Table start and end with no rows between?
pinhtml = ["<!-- all pins hidden -->"] # Avoid Graphviz error
html = [ html = [
row.replace("<!-- connector table -->", "\n".join(pinhtml)) row.replace("<!-- connector table -->", "\n".join(pinhtml))
for row in html for row in html
@ -281,6 +283,7 @@ class Harness:
dot.edge( dot.edge(
f"{connector.name}:p{loop[0]}{loop_side}:{loop_dir}", f"{connector.name}:p{loop[0]}{loop_side}:{loop_dir}",
f"{connector.name}:p{loop[1]}{loop_side}:{loop_dir}", f"{connector.name}:p{loop[1]}{loop_side}:{loop_dir}",
label=" ", # Work-around to avoid over-sized loops.
) )
# determine if there are double- or triple-colored wires in the harness; # determine if there are double- or triple-colored wires in the harness;
@ -292,7 +295,6 @@ class Harness:
) )
for cable in self.cables.values(): for cable in self.cables.values():
html = [] html = []
awg_fmt = "" awg_fmt = ""
@ -530,6 +532,38 @@ class Harness:
fillcolor=translate_color(bgcolor, "HEX"), 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: def typecheck(name: str, value: Any, expect: type) -> None:
if not isinstance(value, expect): if not isinstance(value, expect):
raise Exception( raise Exception(
@ -595,51 +629,9 @@ class Harness:
typecheck("tweak.append", self.tweak.append, str) typecheck("tweak.append", self.tweak.append, str)
dot.body.append(self.tweak.append) dot.body.append(self.tweak.append)
for mate in self.mates: # Tweak processing above must be the last before returning dot.
if mate.shape[0] == "<" and mate.shape[-1] == ">": # Please don't insert any code that might change the dot contents
dir = "both" # after tweak processing.
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]
if (
isinstance(mate, MatePin)
and self.connectors[mate.from_name].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"
):
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 ""
)
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)
dot.edge(code_from, code_to)
return dot return dot
@ -664,7 +656,7 @@ class Harness:
return data.read() return data.read()
@property @property
def svg(self): def svg(self): # TODO?: Verify xml encoding="utf-8" in SVG?
graph = self.graph graph = self.graph
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd()) return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
@ -699,7 +691,7 @@ class Harness:
# BOM output # BOM output
bomlist = bom_list(self.bom()) bomlist = bom_list(self.bom())
if "tsv" in fmt: if "tsv" in fmt:
open_file_write(f"{filename}.bom.tsv").write(tuplelist2tsv(bomlist)) file_write_text(f"{filename}.bom.tsv", tuplelist2tsv(bomlist))
if "csv" in fmt: if "csv" in fmt:
# TODO: implement CSV output (preferrably using CSV library) # TODO: implement CSV output (preferrably using CSV library)
print("CSV output is not yet supported") print("CSV output is not yet supported")

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Please don't import anything in this file to avoid issues when it is imported in setup.py # 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"
CMD_NAME = "wireviz" # Lower case command and module name CMD_NAME = "wireviz" # Lower case command and module name
APP_NAME = "WireViz" # Application name in texts meant to be human readable 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"

View File

@ -8,6 +8,20 @@ from typing import Union
mime_subtype_replacements = {"jpg": "jpeg", "tif": "tiff"} 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: def embed_svg_images(svg_in: str, base_path: Union[str, Path] = Path.cwd()) -> str:
images_b64 = {} # cache of base64-encoded images images_b64 = {} # cache of base64-encoded images
@ -45,8 +59,8 @@ def embed_svg_images_file(
) -> None: ) -> None:
filename_in = Path(filename_in).resolve() filename_in = Path(filename_in).resolve()
filename_out = filename_in.with_suffix(".b64.svg") filename_out = filename_in.with_suffix(".b64.svg")
filename_out.write_text( filename_out.write_text( # TODO?: Verify xml encoding="utf-8" in SVG?
embed_svg_images(filename_in.read_text(), filename_in.parent) embed_svg_images(filename_in.read_text(), filename_in.parent)
) ) # TODO: Use encoding="utf-8" in both read_text() and write_text()
if overwrite: if overwrite:
filename_out.replace(filename_in) filename_out.replace(filename_in)

View File

@ -0,0 +1,52 @@
# 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 `<!-- %`, followed by a keyword, and finally `% -->`.
Note that there must be one single space between `--` and `%` at both ends.
| Placeholder | Replaced by |
| --- | --- |
| `<!-- %generator% -->` | The application name, version, and URL |
| `<!-- %fontname% -->` | The value of `options.fontname` |
| `<!-- %bgcolor% -->` | The HEX color translation of `options.bgcolor` |
| `<!-- %filename% -->` | The output path and filename without extension |
| `<!-- %filename_stem% -->` | The output filename without path nor extension |
| `<!-- %bom% -->` | BOM as HTML table with headers at top |
| `<!-- %bom_reversed% -->` | Reversed BOM as HTML table with headers at bottom |
| `<!-- %sheet_current% -->` | `1` (multi-page documents not yet supported) |
| `<!-- %sheet_total% -->` | `1` (multi-page documents not yet supported) |
| `<!-- %diagram% -->` | Embedded SVG diagram as valid HTML |
| `<!-- %diagram_png_b64% -->` | Embedded base64 encoded PNG diagram as URI |
| `<!-- %{item}% -->` | String or numeric value of `metadata.{item}` |
| `<!-- %{item}_{i}% -->` | Category number `{i}` within dict value of `metadata.{item}` |
| `<!-- %{item}_{i}_{key}% -->` | Value of `metadata.{item}.{category}.{key}` |
| `<!-- %template_sheetsize% -->` | 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
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.

View File

@ -179,7 +179,7 @@
</head> </head>
<body> <body>
<div id="page"> <div id="page">
<div id="frame" class="sheetsize_default"> <div id="frame" class="<!-- %template_sheetsize% -->">
<div id="diagram"> <div id="diagram">

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import platform
import sys import sys
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Tuple, Union from typing import Any, Dict, List, Tuple, Union
@ -14,12 +15,14 @@ from wireviz.DataClasses import Metadata, Options, Tweak
from wireviz.Harness import Harness from wireviz.Harness import Harness
from wireviz.wv_helper import ( from wireviz.wv_helper import (
expand, expand,
file_read_text,
get_single_key_and_value, get_single_key_and_value,
is_arrow, is_arrow,
open_file_read,
smart_file_resolve, smart_file_resolve,
) )
from . import APP_NAME
def parse( def parse(
inp: Union[Path, str, Dict], inp: Union[Path, str, Dict],
@ -86,6 +89,10 @@ def parse(
raise Exception("No output formats or return types specified") raise Exception("No output formats or return types specified")
yaml_data, yaml_file = _get_yaml_data_and_path(inp) yaml_data, yaml_file = _get_yaml_data_and_path(inp)
if not isinstance(yaml_data, dict):
raise TypeError(
f"Expected a dict as top-level YAML input, but got: {type(yaml_data)}"
)
if output_formats: if output_formats:
# need to write data to file, determine output directory and filename # need to write data to file, determine output directory and filename
output_dir = _get_output_dir(yaml_file, output_dir) output_dir = _get_output_dir(yaml_file, output_dir)
@ -117,10 +124,7 @@ def parse(
# When title is not given, either deduce it from filename, or use default text. # When title is not given, either deduce it from filename, or use default text.
if "title" not in harness.metadata: if "title" not in harness.metadata:
if yaml_file is None: harness.metadata["title"] = output_name or f"{APP_NAME} diagram and BOM"
harness.metadata["title"] = "WireViz diagram and BOM"
else:
harness.metadata["title"] = Path(yaml_file).stem
# add items # add items
# parse YAML input file ==================================================== # parse YAML input file ====================================================
@ -205,7 +209,6 @@ def parse(
expected_type = alternating_types[1 - alternating_types.index(expected_type)] expected_type = alternating_types[1 - alternating_types.index(expected_type)]
for connection_set in connection_sets: for connection_set in connection_sets:
# figure out number of parallel connections within this set # figure out number of parallel connections within this set
connectioncount = [] connectioncount = []
for entry in connection_set: for entry in connection_set:
@ -405,14 +408,21 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
try: try:
yaml_path = Path(inp).expanduser().resolve(strict=True) yaml_path = Path(inp).expanduser().resolve(strict=True)
# if no FileNotFoundError exception happens, get file contents # if no FileNotFoundError exception happens, get file contents
yaml_str = open_file_read(yaml_path).read() yaml_str = file_read_text(yaml_path)
except (FileNotFoundError, OSError) as e: except (FileNotFoundError, OSError, ValueError) as e:
# if inp is a long YAML string, Pathlib will raise OSError: [errno.ENAMETOOLONG] # if inp is a long YAML string, Pathlib will normally raise
# when trying to expand and resolve it as a path. # FileNotFoundError or OSError(errno = ENAMETOOLONG) when
# Catch this error, but raise any others # trying to expand and resolve it as a path, but in Windows
from errno import ENAMETOOLONG # might ValueError or OSError(errno = EINVAL or None) be raised
# instead in some cases (depending on the Python version).
# Catch these specific errors, but raise any others.
if type(e) is OSError and e.errno != ENAMETOOLONG: from errno import EINVAL, ENAMETOOLONG
if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG, None):
print(
f"OSError(errno={e.errno}) in Python {sys.version} at {platform.platform()}"
)
raise e raise e
# file does not exist; assume inp is a YAML string # file does not exist; assume inp is a YAML string
yaml_str = inp yaml_str = inp

View File

@ -204,7 +204,9 @@ def generate_bom(harness: "Harness") -> List[BOMEntry]:
bom.append( bom.append(
{ {
**group_entries[0], **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)), "designators": sorted(set(designators)),
} }
) )

View File

@ -11,7 +11,7 @@ if __name__ == "__main__":
import wireviz.wireviz as wv import wireviz.wireviz as wv
from wireviz import APP_NAME, __version__ from wireviz import APP_NAME, __version__
from wireviz.wv_helper import open_file_read from wireviz.wv_helper import file_read_text
format_codes = { format_codes = {
# "c": "csv", # "c": "csv",
@ -111,7 +111,7 @@ def wireviz(file, format, prepend, output_dir, output_name, version):
raise Exception(f"File does not exist:\n{prepend_file}") raise Exception(f"File does not exist:\n{prepend_file}")
print("Prepend file:", prepend_file) print("Prepend file:", prepend_file)
prepend_input += open_file_read(prepend_file).read() + "\n" prepend_input += file_read_text(prepend_file) + "\n"
else: else:
prepend_input = "" prepend_input = ""
@ -130,7 +130,7 @@ def wireviz(file, format, prepend, output_dir, output_name, version):
"Output file: ", f"{Path(_output_dir / _output_name)}.{output_formats_str}" "Output file: ", f"{Path(_output_dir / _output_name)}.{output_formats_str}"
) )
yaml_input = open_file_read(file).read() yaml_input = file_read_text(file)
file_dir = file.parent file_dir = file.parent
yaml_input = prepend_input + yaml_input yaml_input = prepend_input + yaml_input

View File

@ -113,18 +113,31 @@ def clean_whitespace(inp):
def open_file_read(filename): def open_file_read(filename):
"""Open utf-8 encoded text file for reading - remember closing it when finished"""
# TODO: Intelligently determine encoding # TODO: Intelligently determine encoding
return open(filename, "r", encoding="UTF-8") return open(filename, "r", encoding="UTF-8")
def open_file_write(filename): def open_file_write(filename):
"""Open utf-8 encoded text file for writing - remember closing it when finished"""
return open(filename, "w", encoding="UTF-8") return open(filename, "w", encoding="UTF-8")
def open_file_append(filename): def open_file_append(filename):
"""Open utf-8 encoded text file for appending - remember closing it when finished"""
return open(filename, "a", encoding="UTF-8") return open(filename, "a", encoding="UTF-8")
def file_read_text(filename: str) -> str:
"""Read utf-8 encoded text file, close it, and return the text"""
return Path(filename).read_text(encoding="utf-8")
def file_write_text(filename: str, text: str) -> int:
"""Write utf-8 encoded text file, close it, and return the number of characters written"""
return Path(filename).write_text(text, encoding="utf-8")
def is_arrow(inp): def is_arrow(inp):
""" """
Matches strings of one or multiple `-` or `=` (but not mixed) Matches strings of one or multiple `-` or `=` (but not mixed)
@ -144,7 +157,7 @@ def aspect_ratio(image_src):
try: try:
from PIL import Image from PIL import Image
image = Image.open(image_src) with Image.open(image_src) as image:
if image.width > 0 and image.height > 0: if image.width > 0 and image.height > 0:
return image.width / image.height return image.width / image.height
print(f"aspect_ratio(): Invalid image size {image.width} x {image.height}") print(f"aspect_ratio(): Invalid image size {image.width} x {image.height}")

View File

@ -2,15 +2,16 @@
import re import re
from pathlib import Path 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 import APP_NAME, APP_URL, __version__, wv_colors
from wireviz.DataClasses import Metadata, Options 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_gv_html import html_line_breaks
from wireviz.wv_helper import ( from wireviz.wv_helper import (
file_read_text,
file_write_text,
flatten2d, flatten2d,
open_file_read,
open_file_write,
smart_file_resolve, smart_file_resolve,
) )
@ -21,7 +22,6 @@ def generate_html_output(
metadata: Metadata, metadata: Metadata,
options: Options, options: Options,
): ):
# load HTML template # load HTML template
templatename = metadata.get("template", {}).get("name") templatename = metadata.get("template", {}).get("name")
if templatename: if templatename:
@ -34,14 +34,14 @@ def generate_html_output(
# fall back to built-in simple template if no template was provided # fall back to built-in simple template if no template was provided
templatefile = Path(__file__).parent / "templates/simple.html" templatefile = Path(__file__).parent / "templates/simple.html"
html = open_file_read(templatefile).read() html = file_read_text(templatefile) # TODO?: Warn if unexpected meta charset?
# embed SVG diagram # embed SVG diagram (only if used)
with open_file_read(f"{filename}.tmp.svg") as file: def svgdata() -> str:
svgdata = re.sub( return re.sub( # TODO?: Verify xml encoding="utf-8" in SVG?
"^<[?]xml [^?>]*[?]>[^<]*<!DOCTYPE [^>]*>", "^<[?]xml [^?>]*[?]>[^<]*<!DOCTYPE [^>]*>",
"<!-- XML and DOCTYPE declarations from SVG file removed -->", "<!-- XML and DOCTYPE declarations from SVG file removed -->",
file.read(), file_read_text(f"{filename}.tmp.svg"),
1, 1,
) )
@ -80,13 +80,27 @@ def generate_html_output(
"<!-- %generator% -->": f"{APP_NAME} {__version__} - {APP_URL}", "<!-- %generator% -->": f"{APP_NAME} {__version__} - {APP_URL}",
"<!-- %fontname% -->": options.fontname, "<!-- %fontname% -->": options.fontname,
"<!-- %bgcolor% -->": wv_colors.translate_color(options.bgcolor, "hex"), "<!-- %bgcolor% -->": wv_colors.translate_color(options.bgcolor, "hex"),
"<!-- %diagram% -->": svgdata, "<!-- %filename% -->": str(filename),
"<!-- %filename_stem% -->": Path(filename).stem,
"<!-- %bom% -->": bom_html, "<!-- %bom% -->": bom_html,
"<!-- %bom_reversed% -->": bom_html_reversed, "<!-- %bom_reversed% -->": bom_html_reversed,
"<!-- %sheet_current% -->": "1", # TODO: handle multi-page documents "<!-- %sheet_current% -->": "1", # TODO: handle multi-page documents
"<!-- %sheet_total% -->": "1", # TODO: handle multi-page documents "<!-- %sheet_total% -->": "1", # TODO: handle multi-page documents
"<!-- %template_sheetsize% -->": metadata.get("template", {}).get(
"sheetsize", ""
),
} }
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("<!-- %diagram% -->", svgdata)
replacement_if_used(
"<!-- %diagram_png_b64% -->", lambda: data_URI_base64(f"{filename}.png")
)
# prepare metadata replacements # prepare metadata replacements
if metadata: if metadata:
for item, contents in metadata.items(): for item, contents in metadata.items():
@ -97,14 +111,11 @@ def generate_html_output(
if isinstance(entry, Dict): if isinstance(entry, Dict):
replacements[f"<!-- %{item}_{index+1}% -->"] = str(category) replacements[f"<!-- %{item}_{index+1}% -->"] = str(category)
for entry_key, entry_value in entry.items(): for entry_key, entry_value in entry.items():
replacements[f"<!-- %{item}_{index+1}_{entry_key}% -->"] = ( replacements[
html_line_breaks(str(entry_value)) f"<!-- %{item}_{index+1}_{entry_key}% -->"
) ] = html_line_breaks(str(entry_value))
elif isinstance(entry, (str, int, float)):
replacements['"sheetsize_default"'] = '"{}"'.format( pass # TODO?: replacements[f"<!-- %{item}_{category}% -->"] = html_line_breaks(str(entry))
metadata.get("template", {}).get("sheetsize", "")
)
# include quotes so no replacement happens within <style> definition
# perform replacements # perform replacements
# regex replacement adapted from: # regex replacement adapted from:
@ -116,4 +127,4 @@ def generate_html_output(
pattern = re.compile("|".join(replacements_escaped)) pattern = re.compile("|".join(replacements_escaped))
html = pattern.sub(lambda match: replacements[match.group(0)], html) html = pattern.sub(lambda match: replacements[match.group(0)], html)
open_file_write(f"{filename}.html").write(html) file_write_text(f"{filename}.html", html)

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>tutorial01</title> <title>tutorial01</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>tutorial02</title> <title>tutorial02</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>tutorial03</title> <title>tutorial03</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>tutorial04</title> <title>tutorial04</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>tutorial05</title> <title>tutorial05</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>tutorial06</title> <title>tutorial06</title>
<style> <style>

View File

@ -1,6 +1,6 @@
Id Description Qty Unit Designators Id Description Qty Unit Designators
1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6 1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6
2 Wire, 0.25 mm², PK 1.0 m W1, W2, W3, W4, W5 2 Wire, 0.25 mm², PK 1 m W1, W2, W3, W4, W5
3 Wire, 0.25 mm², TQ 1.0 m W1, W2, W3, W4, W5 3 Wire, 0.25 mm², TQ 1 m W1, W2, W3, W4, W5
4 Wire, 0.25 mm², VT 1.0 m W1, W2, W3, W4, W5 4 Wire, 0.25 mm², VT 1 m W1, W2, W3, W4, W5
5 Wire, 0.25 mm², YE 1.0 m W1, W2, W3, W4, W5 5 Wire, 0.25 mm², YE 1 m W1, W2, W3, W4, W5

1 Id Description Qty Unit Designators
2 1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6
3 2 Wire, 0.25 mm², PK 1.0 1 m W1, W2, W3, W4, W5
4 3 Wire, 0.25 mm², TQ 1.0 1 m W1, W2, W3, W4, W5
5 4 Wire, 0.25 mm², VT 1.0 1 m W1, W2, W3, W4, W5
6 5 Wire, 0.25 mm², YE 1.0 1 m W1, W2, W3, W4, W5

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>tutorial07</title> <title>tutorial07</title>
<style> <style>
@ -716,28 +716,28 @@
<tr> <tr>
<td class="bom_col_id">2</td> <td class="bom_col_id">2</td>
<td class="bom_col_description">Wire, 0.25 mm², PK</td> <td class="bom_col_description">Wire, 0.25 mm², PK</td>
<td class="bom_col_qty">1.0</td> <td class="bom_col_qty">1</td>
<td class="bom_col_unit">m</td> <td class="bom_col_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">3</td> <td class="bom_col_id">3</td>
<td class="bom_col_description">Wire, 0.25 mm², TQ</td> <td class="bom_col_description">Wire, 0.25 mm², TQ</td>
<td class="bom_col_qty">1.0</td> <td class="bom_col_qty">1</td>
<td class="bom_col_unit">m</td> <td class="bom_col_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">4</td> <td class="bom_col_id">4</td>
<td class="bom_col_description">Wire, 0.25 mm², VT</td> <td class="bom_col_description">Wire, 0.25 mm², VT</td>
<td class="bom_col_qty">1.0</td> <td class="bom_col_qty">1</td>
<td class="bom_col_unit">m</td> <td class="bom_col_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">5</td> <td class="bom_col_id">5</td>
<td class="bom_col_description">Wire, 0.25 mm², YE</td> <td class="bom_col_description">Wire, 0.25 mm², YE</td>
<td class="bom_col_qty">1.0</td> <td class="bom_col_qty">1</td>
<td class="bom_col_unit">m</td> <td class="bom_col_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4 // Graph generated by WireViz 0.4.1
// https://github.com/formatc1702/WireViz // https://github.com/wireviz/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz"> <meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
<title>tutorial08</title> <title>tutorial08</title>
<style> <style>