From e9a2ec1aa9c70f75e13e7306d42379e21c980e93 Mon Sep 17 00:00:00 2001 From: Milan Rother Date: Wed, 4 Nov 2026 20:39:57 +0100 Subject: [PATCH] Block icons in the template, pypi environment for publishing --- .github/workflows/publish.yml | 1 + TEMPLATE.md | 10 +++++++++- src/pathsim_toolbox/icons/FirstOrderLag.svg | 1 + tests/test_example_block.py | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/pathsim_toolbox/icons/FirstOrderLag.svg diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f65f83f..0fdbd05 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,6 +12,7 @@ permissions: jobs: publish: runs-on: ubuntu-latest + environment: pypi steps: - uses: actions/checkout@v4 with: diff --git a/TEMPLATE.md b/TEMPLATE.md index 9e4540b..5aa767b 100644 --- a/TEMPLATE.md +++ b/TEMPLATE.md @@ -36,6 +36,13 @@ repo, removes the template banner from `README.md`, and finally deletes - `src/pathsim_/example_block.py` — replace `FirstOrderLag` with your real blocks. Keep the structure: header comment, docstring documenting math / parameters / ports, input validation, `*_port_labels`. +- `src/pathsim_/icons/` — one SVG icon per block class, named + `.svg`. `Block.icon()` (pathsim 0.30 and later) reads it from + there and PathView shows it on the canvas. Follow the core icons in + [`pathsim/icons`](https://github.com/pathsim/pathsim/tree/master/src/pathsim/icons): + viewBox `0 0 96 64`, `fill="none" stroke="currentColor" stroke-width="1.6"`, + no colors, since the editor sets them. Blocks without a file have no icon, + and subclasses don't inherit the icon of their parent. - `tests/` — mirror the structure of `src/`. Tests run with both `unittest` and `pytest`; physics is verified through a full `Simulation`. - `docs/source/examples/` — example notebooks. The placeholder is a copied @@ -111,4 +118,5 @@ all rendering. a GitHub Release is published. Versions come from git tags via `setuptools-scm`, so tag releases as `vX.Y.Z`. Configure a [PyPI trusted publisher](https://docs.pypi.org/trusted-publishers/) for the -project pointing at this repo and the `publish.yml` workflow. +project pointing at this repo, the `publish.yml` workflow and the `pypi` +environment. diff --git a/src/pathsim_toolbox/icons/FirstOrderLag.svg b/src/pathsim_toolbox/icons/FirstOrderLag.svg new file mode 100644 index 0000000..fd088d3 --- /dev/null +++ b/src/pathsim_toolbox/icons/FirstOrderLag.svg @@ -0,0 +1 @@ + diff --git a/tests/test_example_block.py b/tests/test_example_block.py index d425cc4..8c12f52 100644 --- a/tests/test_example_block.py +++ b/tests/test_example_block.py @@ -29,6 +29,10 @@ def test_invalid_params(self): with self.assertRaises(ValueError): FirstOrderLag(tau=-1.0) + def test_icon(self): + # read from src/pathsim_toolbox/icons by Block.icon() + self.assertTrue(FirstOrderLag.icon().startswith("