328 Commits

Author SHA1 Message Date
KV
7c2fdd6d5a Improve error handling in aspect_ratio() 2020-08-29 22:43:37 +02:00
KV
ede29cbc95 Make Image.gv_dir an InitVar
It is only used during initialization in the __post_init__() function
and does not need to be a proper attribute of the Image dataclass.
https://docs.python.org/3/library/dataclasses.html#init-only-variables
2020-08-29 22:42:33 +02:00
KV
c0a11d0dfe Simplify the image.fixedsize default value computation 2020-08-29 22:42:05 +02:00
KV
9950f7f76e Improve the image.fixedsize default value computation 2020-08-21 19:47:13 +02:00
KV
19c415c6d7 Add aspect_ratio() function that reads image size from file
- To be able to find an image file with relative path, the directory
  of the .gv file output is injected into each Image data object.
- aspect_ratio() prints a warning and returns 1:1 ratio if it fails.
2020-08-19 11:35:55 +02:00
KV
285a28dff6 Avoid some bad combinations of default values
- Avoid setting image.fixedsize default True when image.scale is
  specified different than "true" or "both" by the user.
- Avoid calculating the missing dimension unless image.fixedsize
  is actually True. It might have been specified False by the user.
2020-08-19 11:35:17 +02:00
KV
c21707980e Test image.width and image.height without using 'is not None'
- Simplification requested by @formatc1702 in review of #153
- Inspection of size_html_cell() in Graphviz source code
  https://gitlab.com/graphviz/graphviz/-/blob/master/lib/common/htmltable.c#L1210-1221
  supports that a zero value is treated as not specified.
2020-08-19 09:48:39 +02:00
KV
0c6b6f390d Compute sensible default values for unspecified image attributes
The goal is to enable the user to avoid specifying more attributes
than strictly needed.
2020-08-16 23:53:12 +02:00
KV
d289f95bc3 Add a minor image scaling to example 08 2020-08-16 16:27:14 +02:00
KV
c23679dd7b Add info about Image dataclass
- Add Optional keyword and value alternatives as requested in review.
- Add a few extra comments about the attributes.
2020-08-16 16:22:56 +02:00
KV
204379a125 Move image attributes into Image dataclass to fix change requests
@formatc1702 requested changes in his review of #153:
- Lowercase attribute values
- Nested image attributes
- Avoid sending the whole node object as argument to helper functions
- Simplify html_size_attr()
- Move the resources folder
2020-08-15 07:13:23 +02:00
KV
3d7f027a4e Add fixedsize as third image_size value
When True, enclose the image cell in a table without borders to avoid
narrow borders when the fixed width is less than the node width.
2020-08-13 22:52:40 +02:00
KV
41b3f3acfe Add an image_size attribute to both Connectors and Cables
It is a list containing minimum width and minimum height of the
image cell. To obtain more available space in the image cell,
this size must be set greater than the natural size of the image.
2020-08-13 22:52:40 +02:00
KV
3dc2a55f81 Add an image_scale attribute to both Connectors and Cables
It specifies how an image will use any extra space available in its
cell. Allowed values are one of these strings:
- FALSE : keep image its natural size. (Default)
- TRUE : scale image uniformly to fit.
- WIDTH : expand image width to fill.
- HEIGHT : expand image height to fill.
- BOTH : expand both image width and height to fill.

The value is sent to Graphviz as a scale attribute to the <img> tag.
Note that there is normally no extra height in the image cell.
2020-08-13 22:52:40 +02:00
KV
06e6c49aa9 Expand example 08 with images and captions
- Stereo phone plug (a slight modification of a public domain image
  from https://openclipart.org/detail/192396/headphones-connctor ).
- Cable cross-section drawn to match the wire colors in example 08.
- Make the cable jacket and shield colors match the cross-section.
- Images for embedding in the connector and cable nodes are stored
  in a new resources folder.
2020-08-13 22:51:21 +02:00
KV
0cb7118930 Remove border between image and caption
Adding helper function for each of these with a leading <tdX> tag that
instructs nested_html_table() to inject attributes to the <td> tag.
2020-08-13 19:19:50 +02:00
KV
c8c4005487 Add a caption attribute to both Connectors and Cables 2020-08-13 19:14:09 +02:00
KV
43ec3bf798 Add an image attribute to both Connectors and Cables 2020-08-13 19:14:09 +02:00
Daniel Rojas
e3fb39f5ae Add whitespace to GraphViz HTML for readability 2020-08-13 17:21:42 +02:00
Daniel Rojas
94faec536e Rebuild GV HTML generation using lists
Simplify code

remove superfluous temporary variables `pinlist`, `wirerow`

Add suggested changes
2020-08-13 17:21:42 +02:00
Daniel Rojas
af196dfd8c Improve line break handling 2020-08-13 17:21:42 +02:00
Daniel Rojas
102c7d6113 Simplify code and rename variables
Improve code based on review

Suggestions by @kvid
2020-08-13 17:21:42 +02:00
Daniel Rojas
43f85aedb2 Add color attribute to cables 2020-08-13 17:21:42 +02:00
Daniel Rojas
2639c77360 Refactor cable GraphViz HTML generation
to match the one for connectors.
2020-08-13 17:21:42 +02:00
Daniel Rojas
79e751dca8 Remove obsolete code 2020-08-13 17:21:42 +02:00
Marc Brückner
19b82e9662 fix #149 introduced in #147 2020-08-12 18:06:06 +02:00
Marc Brückner
84edda64df
Extend unknown color error message (#147) 2020-08-10 20:13:13 +02:00
Daniel Rojas
4802705427 Improve handling of strings with '-' in wv_helper.expand()
Fixes #139
2020-08-10 17:04:23 +02:00
KV
9a3b8bce6e Add 25-pair comments and split lines according to coloring pattern
The coloring pattern is briefly explained. By splitting the source
code lines into 10 pairs per line, the pattern is more easily seen.
2020-08-10 16:51:17 +02:00
KV
113a7310e1 Replace 20 YW color codes with YE to avoid Unknown color specified
Fixes bug #144
2020-08-10 16:51:17 +02:00
Daniel Rojas
23c17e66bf Change wire padding behavior
Addresses #131
2020-07-27 22:40:59 +02:00
KV
99ca1859eb Fix change requests from owner as descibed in PR #118
- Add double quotes around path string in `os.system()` call and
  status output to handle any spaces in the path.
- Split the `generated_extensions` list into the two lists
  `extensions_not_containing_graphviz_output` and
  `extensions_containing_graphviz_output` for readability.
2020-07-27 20:14:14 +02:00
KV
21db0d509e Add CLI option -c that allows comparing Graphviz output also 2020-07-27 20:14:14 +02:00
KV
378e13b988 Move group loop into build_generated() for consistency
Now, all action functions are called with a group list as argument.
2020-07-27 20:14:14 +02:00
KV
94ca9cc358 Restructure the group dict initialization
By putting all value entries on separate lines with a trailing comma,
it becomes easier to read the diff when later inserting or deleting
the first or last value entry in any dict.
2020-07-27 20:14:14 +02:00
KV
476f85bcf5 Make all actions honor the optional argument -g or --group
This make it possible to append '-g' or '--groups' followed by
space separated group names to any CLI action command, and the
set of generated files affected by the command will be limited
to the selected groups ('examples', 'tutorial', and 'demos').
Default is all groups. A simple help text is added for each of
the arguments (action and groups) to improve the autogenerated
CLI help output.

This is a squash rebase of these commits:
- p ec29076 Make all actions honor the optional argument -generate
- s e3ad11a Move open_file_append() outside the if to avoid re-open
- s ba4b900 Avoid including readme in all file groups
- s 1ca8bd1 Simplify code
- s a9e7337 Rename some variables to better reflect their contents and relations
- s 58a54b2 Move test to include readme inside collect_filenames() function
- s f2a0db0 Improve status output by adding group name
- s d3b299b Rename -generate option to -g/--groups and add argument help
2020-07-27 20:14:14 +02:00
KV
4eedd94164 Add actions to compare against and restore from the latest commit
Add new actions:
- 'compare' action to compare generated files (except those
  generated by Graphviz) against the latest commit, and
- 'restore' action to restore generated files from the latest commit.

This is a squash rebase of these commits:
- p 9ad3e13 Reduce code duplication by moving common code into a generic function
- s d4feae6 Add action to restore generated files from git repository
- s 64f6507 Add action to compare generated files against git repository
- s 099c202 Simplify code
2020-07-27 20:14:14 +02:00
Daniel Rojas
3fa015cabd Refactor build_examples.py
- Use `pathlib.Path` instead of `os.path`
- Fix order of files while building
- Consolidate code for building demos, examples and tutorial
- Change argument from `tutorials` to `tutorial` to remain consistent
- Add some indentation in console output for better readability
2020-07-27 20:14:14 +02:00
KV
1815a13cd6 Make each shield wire uniform and allow cable.shield color
As the spline shield wires were rendered as tinned wires with
black borders, and the shield wires in cable nodes were rendered
as a single (bottom) border, they didn't fit well together.

Each shield wire is now rendered equally along the spline sections
and in cable nodes. If cable.shield is true, they are rendered as
thin black wires in the same way as before multi-colors were
introduced. The new feature is that cable.shield is allowed to
contain a two-letter color code to specify a colored shield wire
with black borders.

The shield wire thickness is not increased, even if the cable has
some multi-colored wires that makes all other wires to increase.

This fixes bug #125.
2020-07-27 20:11:47 +02:00
Tyler Ward
b9a4783b6f
Shorten BOM field names (#121)
- Shorten `part_number` to `pn`
- Shorten `manufacturer_part_number` to `mpn`
- Show `manufacturer` and `mpn` in a single cell of the node
- Replace `manufacturer` with `'MPN'`within the node if no manufacturer is specified.
- Rearrange order of P/N fields within node
  `{pn} | {manufacturer}: {mpn}`
2020-07-26 16:50:11 +02:00
Daniel Rojas
f2f654854a Update README.md
Denote that WireViz reads and writes files in UTF-8 (or UTF-8 compatible) encodings, to disclaim against non UTF-8 input files.
2020-07-21 22:29:38 +02:00
Daniel Rojas
a69fc76651 Rebuild examples 2020-07-21 22:08:25 +02:00
Daniel Rojas
2a963bfef6 Update example input files 2020-07-21 22:01:10 +02:00
Daniel Rojas
a1881eb49d Rename connector attributes (#77)
Rename `pinnumbers` to `pins`.
Rename `pinout` to `pinlabels`.
2020-07-21 22:01:10 +02:00
Daniel Rojas
6468c0e2a5 Change code for silver and gold
Change to SR and GD to match the [standard](https://en.wikipedia.org/wiki/Electronic_color_code#Color_band_system)
2020-07-21 21:34:48 +02:00
Daniel Rojas
a632dc6cb8 Fix HTML color code appearing in wire node
...when no color is specified.
2020-07-20 15:46:18 +02:00
Daniel Rojas
b028e7a22b
Fix node rendering for cables with hidden name and/or no visible attributes (#104)
Closes #69.
2020-07-20 14:24:39 +02:00
Jason
a418005c2e
Fix superscript 2 in HTML output (#95)
Change `<sup></sup>` to `&sup2;`
2020-07-20 13:19:04 +02:00
Daniel Rojas
a8b2dc3572 Add new colors (olive green, light blue, beige, ivory)
This might be useful for some more exotic [ferrule colors](https://de.wikipedia.org/wiki/Aderendh%C3%BClse#Farbliche_Markierung)
2020-07-20 13:02:16 +02:00
Daniel Rojas
8f833d9da5 Rebuild examples 2020-07-20 08:21:54 +02:00