Skip to content

feat: upstream batch C — include, twisted pairs, shorts, sheet PDF, errors - #16

Merged
SomethingNew71 merged 14 commits into
masterfrom
fix/upstream-batch-c
Oct 3, 2026
Merged

SomethingNew71 merged 14 commits into
masterfrom
fix/upstream-batch-c

Conversation

@SomethingNew71

Copy link
Copy Markdown

Summary

Batch C: larger features from upstream wireviz/WireViz issues. The design is in docs/plans/2026-10-02-batch-c-design.md; the open decisions were confirmed on 2026-10-02. Based on batch B.

The sheet PDF only reads inline data: content. In untrusted mode it runs in a time-limited child process that cannot import a package from the working directory.

Review

Two Code Reviewer rounds (Opus). Every finding is fixed, with tests.

Test plan

  • pytest on Python 3.9, 3.12 and 3.14: 350 passed, 8 skipped; 358 passed with WeasyPrint
  • Sheet PDFs of demo01 (A4) and demo02 (A3) checked visually
  • Gallery: Graphviz source and BOM unchanged
  • CI green (CI now installs Pango and wireviz[pdf])

🤖 Generated with Claude Code

…ireviz#505, wireviz#207, wireviz#508

- every error raised while a connection set is processed is prefixed
  with 'connection set N (X1 → W1 → X2): '; ValueError/TypeError keep
  their class, anything else becomes wv_errors.WireVizError(ValueError)
- the CLI prints input errors as one line (exit 1); --debug re-raises
- a cable without wirecount/colors takes its wire count from the wire
  numbers used for it (all sets; per template instance)
- behavior change: a bare named cable (- B1) uses wires 1..n instead of
  wire 1 n times; autogenerated '- W.' is unchanged
- clearer style: simple and unknown-wire-count messages
…s — wireviz#220

- include: [file, ...] merges connectors and cables by name (main file
  wins; the same name in two includes is an error naming both files) and
  appends additional_bom_items; metadata/options/tweak/connections stay
  main-file only
- nested includes, cycle and depth checks; paths relative to the
  including file, then -I/--include-path / parse(include_paths=...)
- relative image paths in an included file resolve against that file
- PNG output embeds the merged YAML; untrusted mode refuses include
- docs: include and --prepend in syntax.md
…wireviz#353

Cable twisted: [[RD, BK], {wires: [3, 4], rate: 20/m}] lists each group's
wires together, framed (solid border; dashed means a shield) with a
caption such as 'Twisted pair: 20/m'. Wires are referenced by number,
color or label; ports keep the wire number, so edges do not change.
Errors for a group under 2 wires, a wire in two groups, unknown wires.
…ireviz#350

Connector shorts: [[1, 2, 3], {YE: [N, AUX]}] draws each short as a
solid bar column next to the ports, with a dot at every shorted pin
(pins by number or label, optional color). Shorted pins are activated,
so they stay visible with hide_disconnected_pins and count as populated.
Plain HTML table cells; no gvpr/neato post-processing.
…reviz#32, wireviz#304

- new output format sheet (-f D, <name>.sheet.pdf): the HTML page
  rendered to one PDF page at the template's sheet size; optional extra
  wireviz[pdf] (WeasyPrint); its URL fetcher refuses every URL
- din-6771 template: flex layout so the diagram scales into the space
  above the BOM and title block (no overlap), named @page per sheet size
  (A4 portrait, A3/A2 landscape), A4 when sheetsize is not set
- simple template: print CSS fits the diagram to the page
- new <!-- %date% --> placeholder; -f P is unchanged (diagram-only PDF)
- CI installs Pango and wireviz[pdf] so the sheet tests run
- sheet PDF: WeasyPrint gets a URLFetcher that allows data: URLs only
  (the refuse-all function dropped every inline image and, on 70, raised
  for any URL); requires weasyprint>=70; untrusted mode renders in a
  child process with the render timeout
- shorts: at most 64 per connector; spans computed once per connector
  (was O(pins^2 x shorts)); short colors must resolve to #rrggbb
- include: a file reached through two includes (diamond) is merged once;
  conflicts name the defining files; non-UTF-8 includes name the file;
  symlinked includes resolve relative paths next to the link
- wireviz#508: bare references to named template instances use wires 1..n and
  feed the wire-count pre-pass; out-of-range errors for a bare cable
  explain the change; the pre-pass skips malformed entries so the main
  loop reports them with context
- errors: only ValueError/TypeError/plain Exception get connection-set
  context (other exceptions are bugs and pass through); the CLI prints
  input and environment errors (incl. missing WeasyPrint or Graphviz) as
  one line
- warnings when shorts (style: simple) or twisted (show_box: false) are
  not shown; metadata.date wins over the built-in date placeholder;
  simple template prints at the browser's page size
- tests: sheet images and no-fetch, untrusted sheet timeout, WeasyPrint
  probed per test, not at collection
- sheet PDF child: runs with -c and sys.path[0] set to this package's
  root ('python -m' imported a 'wireviz' from the working directory);
  memory limited on POSIX; failures raise WireVizRenderError
- connection sets: a set that is not a list, an empty mapping or an
  empty list is a clear input error with set context (was IndexError /
  RuntimeError without context)
- shorts: pins x shorts over all connectors is capped (100 000 cells),
  so YAML aliases cannot multiply the label size
- include: a file reached twice adds its BOM items once (shared set
  through the recursion)
- CLI: catches WireVizRenderError and graphviz.ExecutableNotFound, not
  every RuntimeError
- %date%: an unquoted YAML date works; null or no metadata.date falls
  back to today
- the wireviz#508 hint names the real cable; tests spy the WeasyPrint fetcher
  and cover the cwd package, malformed sets, diamond BOM items
@SomethingNew71
SomethingNew71 changed the base branch from fix/upstream-batch-b to master October 2, 2026 22:51
…thon 3.10+

WeasyPrint installed but did not load on the runner, so all 8 sheet tests
were skipped. CI now installs the missing library and sets
WIREVIZ_REQUIRE_PDF, which turns that skip into a failure with the
reason (pytest -rs).
@SomethingNew71
SomethingNew71 merged commit c3b9e63 into master Oct 3, 2026
24 checks passed
@SomethingNew71
SomethingNew71 deleted the fix/upstream-batch-c branch October 3, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant