396 Commits

Author SHA1 Message Date
Daniel Rojas
c1494db571
Equalize line weights and simplify CSS
Experiments in exporting PDF using `wkhtmltopdf` utility caused borders to disappear when set to 0.25mm, but 0.35mm renders fine
2023-01-19 16:35:15 -05:00
Daniel Rojas
fd8749bab2
Apply suggestions from code review
Co-authored-by: kvid <kvid@users.noreply.github.com>
2023-01-19 16:35:15 -05:00
Daniel Rojas
e2f1a4eff1
Apply suggestions from code review
Co-authored-by: kvid <kvid@users.noreply.github.com>
2023-01-19 16:35:15 -05:00
Daniel Rojas
359cd8d936
Update smart_file_resolve() 2023-01-19 16:35:14 -05:00
Daniel Rojas
ef69d7e4e7
Use regex-based replacement 2023-01-19 16:35:14 -05:00
Daniel Rojas
a80192b82a
Implement fontname and bgcolor(WIP) replacement 2023-01-19 16:35:14 -05:00
Daniel Rojas
928f607457
Consolidate code for replacing HTML placeholders 2023-01-19 16:35:13 -05:00
Daniel Rojas
cf5315d01c
Apply fontname and bgcolor to output HTML
Co-authored-by: kvid <kvid@users.noreply.github.com>
2023-01-19 16:35:13 -05:00
Daniel Rojas
ea89dd4fe0
Add type hint
Co-authored-by: kvid <kvid@users.noreply.github.com>
2023-01-19 16:35:12 -05:00
Daniel Rojas
a9c1724dcb
Add template metadata to demo02.yml 2023-01-19 16:35:12 -05:00
Daniel Rojas
a839a47c3f
Implement template-based HTML output 2023-01-19 16:35:12 -05:00
Daniel Rojas
d44b649fcc
Refactor functions for harness building
- Use pin names instead of pin indices, until the last moment when generating the ports for the GraphViz nodes
- `Harness.add_mate_pin()` now uses pin names
- Remove unused `if is_arrow()` check from `Harness.connect()`
- Consolidate calling of `Connector.activate_pin()` to prevent subtle bugs
  - Call it from `connect()` and `add_mate_pin()`
  - No longer call it from `create_graph()`
- Misc. other tuning
2023-01-19 16:35:11 -05:00
Daniel Rojas
37cd08d476
Simplify code 2023-01-19 16:35:11 -05:00
Daniel Rojas
bc5ef2ecce
Fix bug of arrows using the wrong port IDs 2023-01-19 16:35:11 -05:00
Daniel Rojas
22e75f918e
Fix duplicates in syntax.md after rebase 2023-01-19 16:35:10 -05:00
Daniel Rojas
5cc133c596
Move selected test files to examples directory 2023-01-19 16:35:10 -05:00
Daniel Rojas
aa81c18609
Update syntax description (autogeneration, arrows)
Moved metadata and options info further down, so that the core functionality (connectors, cables, connection sets) comes first.
2023-01-19 16:35:09 -05:00
Daniel Rojas
def03d1ce3
Resolve component level mate not revealing connection count 2023-01-19 16:35:09 -05:00
Daniel Rojas
f20f313af0
Resolve edge case of empty HTML tables 2023-01-19 16:35:09 -05:00
Daniel Rojas
e3fbc91312
Squash feature/mate+autogenerate branch 2023-01-19 16:35:08 -05:00
Daniel Rojas
211ded0c71
Bump version in generated files
`.gv` and `.html` files include the version number as a comment.
Rebuild to avoid diffs during development
2023-01-19 16:34:43 -05:00
Daniel Rojas
4c97195e0e
Bump version to 0.4-dev 2023-01-19 16:34:43 -05:00
Daniel Rojas
b0d0070f08 Bump version to 0.3.2 v0.3.2 2021-11-27 13:32:40 +01:00
Julien Lecoeur
9af0cb8ab0 Fix graphviz file header
The two header comments were missing an endline.

Closes #258
2021-11-27 13:27:22 +01:00
Daniel Rojas
7f33517a79 Bump version to 0.3.1 v0.3.1 2021-10-25 20:13:24 +02:00
Andreas Motl
80b7a5407b Improve gracefulness when invoking wireviz.parse() without file_out
This happened to be a regression for WireViz-Web [1], which aims to do
as much in memory as possible.

[1] https://github.com/daq-tools/wireviz-web.
2021-10-25 20:05:05 +02:00
Daniel Rojas
be1ecd4f63 Merge branch 'dev' v0.3 2021-10-11 21:20:12 +02:00
Daniel Rojas
eb7be156fa Rebuild examples 2021-10-11 20:59:18 +02:00
Daniel Rojas
2629e1c0da Bump version to 0.3 2021-10-11 20:55:53 +02:00
Daniel Rojas
36dfaea1f6 Update changelog 2021-10-11 20:54:39 +02:00
Daniel Rojas
3cc36e1573 Harmonize shebangs and encoding info
- Use `#!/usr/bin/env python3` on executable modules
- Remove shebangs on all other `.py` files
- Add UTF-8 encoding info where mising
2021-10-11 20:05:52 +02:00
Daniel Rojas
255569aec5 Add syntax documentation for cable length units
and reword `shield` explanation
2021-10-05 18:29:51 +02:00
Daniel Rojas
869ad6b8be Rearrange syntax description
Move metadata and options info further down, so that the core functionality (connectors, cables, connection sets) comes first.
2021-10-05 18:15:25 +02:00
Daniel Rojas
48d2e7b0ec Add temp/ to .gitignore 2021-10-03 21:37:09 +02:00
KV
7125f28760 Move color type aliases into wv_colors.py to avoid circular imports 2021-09-28 19:14:28 +02:00
KV
c34946183e Support specifying hex colors for any color attributes 2021-09-28 19:14:28 +02:00
KV
b3fdd48a83 Support specifying hex colors where no color name is needed
This was requested by designer2k2 in #219 for bgcolor usage.
It has also been discussed in #135.

The input validation is more detailed to help the user identifying
and locating invalid values. The wire color padding is now done on
the output to cover different input alternatives.
2021-09-28 19:14:28 +02:00
KV
166ab2fdf1 Support bgcolor of additional components
Maybe not needed that much, but mainly for consistency, to support
bgcolor in all dataclasses that represent boxes in the diagram.
2021-09-28 19:14:28 +02:00
KV
324508a8ee Support image.bgcolor to enable adapting to image colors 2021-09-28 19:14:28 +02:00
KV
45d7d03fe0 Support both bgcolor and bgcolor_title attributes
Solves #210 completely by supporting bgcolor of both the node title
and the whole node independently using separate attributes.
2021-09-28 19:14:28 +02:00
KV
dbccb77b08 Add bgcolor attribute to connectors and cables
This solves the #210 suggestion to render the title row of
the graph nodes with this bgcolor.
2021-09-28 19:14:28 +02:00
Daniel Rojas
a3eefe6659
Implement suppliers and supplier part numbers (#241)
Co-authored-by: kvid <kvid@users.noreply.github.com>
2021-09-14 19:29:59 +02:00
kvid
db05514469
Add optional tweaking of the .gv output (#215)
Co-authored-by: Daniel Rojas <github@danielrojas.net>
2021-09-14 19:20:51 +02:00
kvid
92354e6852
Add basic options and metadata (#214) 2021-08-25 19:46:37 +02:00
Daniel Rojas
e212fc9058
Use unique index for connector pin ports (#229)
Closes #160.

Co-authored-by: kvid <kvid@users.noreply.github.com>
2021-08-23 19:26:23 +02:00
Daniel Rojas
a36807293a Update changelog for #197 2021-08-22 18:43:16 +02:00
kvid
31d55ff775
Simplify BOM code (#197)
* Skip assignment and return expression directly

* Simplify get_bom_index() parameters

- Use the actual BOM as first parameter instead of the whole harness.
- Use a whole AdditionalComponent as second parameter instead of each
  attribute separately.

* Use the same lambda in get_bom_index() as for deduplicating BOM

Move the lambda declaration out of the function scope for common
access from two different functions.

* Convert dataclass object to dict to use the same lambda

* Redefine the common lambda to an ordinary function

* Simplify BOM header row logic

* Simplify collecting designators for a joined BOM entry

Assign input designators once to a temporary variable for easy reusage.

* Simplify deduplication and sorting of collected designators

* Remove parentheses around return expressions

https://stackoverflow.com/questions/4978567/should-a-return-statement-have-parentheses

* Move out code from inner loop into helper functions

* Move BOM sorting above grouping to use groupby()

- Use one common entry loop to consume iterator only once.
- Use same key function for sort() and groupby(),
  except replace None with empty string when sorting.

* Make the BOM grouping function return string tuple for sorting

* Use a generator expressions and raise exception if failing

Seems to be the most popular search alternative:
 https://stackoverflow.com/questions/8653516/python-list-of-dictionaries-search

Raising StopIteration if not found is better than returning None
to detect such an internal error more easily.

* Replace accumulation loop with sum expressions

Make a list from the group iterator for reusage in sum expressions
and to pick first group entry. The expected group sizes are very small,
so performance loss by creating a temporary list should be neglectable.

Alternativly, itertools.tee(group, 3) could be called to triplicate
the iterator, but it was not chosen for readability reasons.

* Add function type hints and doc strings

* Add BOMEntry type alias

This type alias describes the possible types of keys and values in
the dict representing a BOM entry.

* Rename extra variable to part for consistency

* Build output string in one big expression

Build output string in component_table_entry() as the similar strings
in generate_bom(). Repeating a couple of minor if-expressions is small
cost to obtain a more compact and readable main expression.

* Move default qty value=1 to BOM deduplication

* Eliminate local variable

* Rename the 'item' key to 'description' in all BOMEntry dicts

This way, both BOM and harness.additional_bom_items uses the same
set of keys in their dict entries. This was originally suggested
in a #115 review, but had too many issues to be implemented then.

* Move repeated code into new optional_fields() function

* Group common function arguments into a dict

* Revert "Use a generator expressions and raise exception if failing"

This reverts commit 96d393dfb757afc61ffb319c34035d8d2ce7c33d.
However, raising an exception if failing the BOM index search is still
wanted, so a custom exception is raised instead of returning None.

* Use new BOMKey type alias for get_bom_index() target argument

Replace the get_bom_index() part argument with the target key argument
to prepare for quering any BOM entry that matches the target key.

* Cache the BOM entry key in the entry itself

* Rename bom_types_group() to bom_entry_key()

* Define tuples of BOM columns as common constants

* Clarify a comment

* Change BOM heading from `Item` to `Description`

Co-authored-by: kvid <kvid@users.noreply.github.com>

Co-authored-by: Daniel Rojas <github@danielrojas.net>
2021-08-22 18:34:37 +02:00
Daniel Rojas
cf919770da Update contribution guidelines
...to include changes to `syntax.md` if relevant.
2021-03-23 11:58:14 +01:00
Daniel Rojas
cbc30b7323
Update changelog and syntax documentation 2021-03-23 11:53:02 +01:00
Daniel Rojas
71a1c52e22 Remove . from requirements.txt
Closes #172.
2021-03-20 14:20:10 +01:00