sieve-notes 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/CHANGELOG.md +8 -0
  2. {sieve_notes-0.3.0/sieve_notes.egg-info → sieve_notes-0.3.1}/PKG-INFO +2 -2
  3. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/README.ja.md +1 -1
  4. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/README.md +1 -1
  5. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/docs/formats.md +1 -1
  6. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/docs/resolution.md +1 -1
  7. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/docs/vocabulary.md +1 -1
  8. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/pyproject.toml +1 -1
  9. {sieve_notes-0.3.0 → sieve_notes-0.3.1/sieve_notes.egg-info}/PKG-INFO +2 -2
  10. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/sieve_notes.py +81 -22
  11. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/tests/test_notes_nt.py +225 -33
  12. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/LICENSE +0 -0
  13. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/MANIFEST.in +0 -0
  14. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/conftest.py +0 -0
  15. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/docs/convert.md +0 -0
  16. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/docs/graph.md +0 -0
  17. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/docs/plan.md +0 -0
  18. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/examples/README.md +0 -0
  19. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/examples/vault_mixed/meeting.md +0 -0
  20. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/examples/vault_mixed/overview.md +0 -0
  21. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/examples/vault_outline/meeting.md +0 -0
  22. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/examples/vault_outline/reading.md +0 -0
  23. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/examples/vault_wikilink/daily/2026-11-28.md +0 -0
  24. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/examples/vault_wikilink/ideas/plan.md +0 -0
  25. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/examples/vault_wikilink/index.md +0 -0
  26. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/setup.cfg +0 -0
  27. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/sieve_notes.egg-info/SOURCES.txt +0 -0
  28. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/sieve_notes.egg-info/dependency_links.txt +0 -0
  29. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/sieve_notes.egg-info/entry_points.txt +0 -0
  30. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/sieve_notes.egg-info/top_level.txt +0 -0
  31. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/tests/public_text_baseline.json +0 -0
  32. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/tests/test_public_text.py +0 -0
  33. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/tools/check_public_text.py +0 -0
  34. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/tools/check_release_assets.py +0 -0
  35. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/tools/check_release_version.py +0 -0
  36. {sieve_notes-0.3.0 → sieve_notes-0.3.1}/tools/extract_changelog.py +0 -0
@@ -1,3 +1,11 @@
1
+ ## [0.3.1] - 2026-12-02
2
+
3
+ ### Fixed
4
+
5
+ - In the `graph` SVG (the `links` and `folders` views), every edge now starts on the boundary of its source node and ends on the boundary of its target node (within a pixel), so the arrowhead touches the target node instead of stopping short of it.
6
+ - An unknown `--format` for `index`, `blocks` and `convert` (for example `--format yaml`) now exits with the closed error word `invalid_option` and exit code 2, like every other invalid option. The valid outputs are unchanged.
7
+ - The version statements in `docs/formats.md` and `docs/resolution.md` show the current version.
8
+
1
9
  ## [0.3.0] - 2026-12-02
2
10
 
3
11
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sieve-notes
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Deterministic observation and conversion for Markdown note vaults: note relations, block trees, document-outline round trips, link graphs and placement plans
5
5
  Author: Kai IWASAKI
6
6
  License-Expression: MIT
@@ -20,7 +20,7 @@ Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Dynamic: license-file
22
22
 
23
- # Sieve Notes v0.3.0
23
+ # Sieve Notes v0.3.1
24
24
 
25
25
  English | [日本語](https://github.com/neguseatama/sieve-notes/blob/main/README.ja.md)
26
26
 
@@ -1,4 +1,4 @@
1
- # Sieve Notes v0.3.0
1
+ # Sieve Notes v0.3.1
2
2
 
3
3
  [English](https://github.com/neguseatama/sieve-notes/blob/main/README.md) | 日本語
4
4
 
@@ -1,4 +1,4 @@
1
- # Sieve Notes v0.3.0
1
+ # Sieve Notes v0.3.1
2
2
 
3
3
  English | [日本語](https://github.com/neguseatama/sieve-notes/blob/main/README.ja.md)
4
4
 
@@ -1,6 +1,6 @@
1
1
  # Supported formats and sources
2
2
 
3
- The formats that Sieve Notes 0.2.0 covers, with their sources (official
3
+ The formats that Sieve Notes 0.3.1 covers, with their sources (official
4
4
  documentation). Formats are described by the name of the format itself. A
5
5
  format that could not be confirmed in official documentation is listed under
6
6
  "Not covered" and is not implemented in this version.
@@ -1,6 +1,6 @@
1
1
  # Link resolution rules
2
2
 
3
- The rules by which Sieve Notes 0.1.0 resolves links. The official
3
+ The rules by which Sieve Notes 0.3.1 resolves links. The official
4
4
  documentation listed in `docs/formats.md` is the basis for these rules. Where
5
5
  the documentation is silent, the rule written here is the default.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Closed vocabulary and output contract
2
2
 
3
- The words that appear in the output of Sieve Notes 0.3.0 are limited to the
3
+ The words that appear in the output of Sieve Notes 0.3.1 are limited to the
4
4
  closed lists below. No other word is emitted.
5
5
 
6
6
  ## Link kinds
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sieve-notes"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "Deterministic observation and conversion for Markdown note vaults: note relations, block trees, document-outline round trips, link graphs and placement plans"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Kai IWASAKI" }]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sieve-notes
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Deterministic observation and conversion for Markdown note vaults: note relations, block trees, document-outline round trips, link graphs and placement plans
5
5
  Author: Kai IWASAKI
6
6
  License-Expression: MIT
@@ -20,7 +20,7 @@ Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Dynamic: license-file
22
22
 
23
- # Sieve Notes v0.3.0
23
+ # Sieve Notes v0.3.1
24
24
 
25
25
  English | [日本語](https://github.com/neguseatama/sieve-notes/blob/main/README.ja.md)
26
26
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python3
2
- """sieve_notes.py — Sieve Notes 0.3.0 (stage 1: observation and conversion engine).
2
+ """sieve_notes.py — Sieve Notes 0.3.1 (stage 1: observation and conversion engine).
3
3
 
4
4
  Command-line tool and library for Markdown note vaults.
5
5
 
@@ -31,7 +31,7 @@ import unicodedata
31
31
  from math import isqrt
32
32
  from pathlib import Path
33
33
 
34
- __version__ = "0.3.0"
34
+ __version__ = "0.3.1"
35
35
  NOTES_VERSION = 1
36
36
 
37
37
  # ---------------------------------------------------------------- vocabulary
@@ -1785,6 +1785,63 @@ _GRAPH_GAP_X = 32 # gutter between two tree columns
1785
1785
  _GRAPH_LABEL_PAD = 16 # horizontal padding inside a node box
1786
1786
  _GRAPH_BASE_RADIUS = 90
1787
1787
  _GRAPH_LABEL_RADIUS = 26 # label distance outside the circle radius
1788
+ _GRAPH_CORNER_R = 6 # corner radius of the folder rectangles
1789
+
1790
+
1791
+ def _shape_boundary(kind, cx, cy, half_w, dx, dy):
1792
+ """The point on the node shape boundary along the direction (dx, dy)
1793
+ from the shape center, in integer arithmetic (rounding keeps the point
1794
+ within a pixel of the exact boundary).
1795
+
1796
+ Notes are ellipses (half_w x half height); folders are rectangles with
1797
+ rounded corners (corner radius _GRAPH_CORNER_R). The direction is the
1798
+ tangent of the edge at the endpoint, so the edge touches the shape
1799
+ where it actually arrives."""
1800
+ if dx == 0 and dy == 0:
1801
+ return cx, cy
1802
+ if kind != "folder":
1803
+ qx = dx * _SCALE // half_w
1804
+ qy = dy * _SCALE // _GRAPH_NODE_HALF_H
1805
+ q = isqrt(qx * qx + qy * qy)
1806
+ bx = cx + (dx * _SCALE + q // 2) // q
1807
+ by = cy + (dy * _SCALE + q // 2) // q
1808
+ return bx, by
1809
+ hw = half_w
1810
+ hh = _GRAPH_NODE_HALF_H
1811
+ cr = _GRAPH_CORNER_R
1812
+ # intersection with the plain rectangle (scaled parameter)
1813
+ cand = []
1814
+ if dx:
1815
+ edge = cx + hw if dx > 0 else cx - hw
1816
+ cand.append((edge - cx) * _SCALE // dx)
1817
+ if dy:
1818
+ edge = cy + hh if dy > 0 else cy - hh
1819
+ cand.append((edge - cy) * _SCALE // dy)
1820
+ t_rect = min(t for t in cand if t > 0)
1821
+ bx = cx + (t_rect * dx + _SCALE // 2) // _SCALE
1822
+ by = cy + (t_rect * dy + _SCALE // 2) // _SCALE
1823
+ if abs(bx - cx) < hw - cr or abs(by - cy) < hh - cr:
1824
+ return bx, by # a straight edge, not a corner
1825
+ # the hit falls in a corner square: the boundary there is the arc
1826
+ kx = cx + (hw - cr if dx > 0 else -(hw - cr))
1827
+ ky = cy + (hh - cr if dy > 0 else -(hh - cr))
1828
+ fx = cx - kx
1829
+ fy = cy - ky
1830
+ a = dx * dx + dy * dy
1831
+ b = 2 * (fx * dx + fy * dy)
1832
+ c0 = fx * fx + fy * fy - cr * cr
1833
+ disc = b * b - 4 * a * c0
1834
+ if disc < 0:
1835
+ return bx, by
1836
+ sd = isqrt(disc)
1837
+ roots = [r for r in (((-b - sd) * _SCALE) // (2 * a),
1838
+ ((-b + sd) * _SCALE) // (2 * a)) if r > 0]
1839
+ if not roots:
1840
+ return bx, by
1841
+ t_arc = min(roots)
1842
+ ax = cx + (t_arc * dx + _SCALE // 2) // _SCALE
1843
+ ay = cy + (t_arc * dy + _SCALE // 2) // _SCALE
1844
+ return ax, ay
1788
1845
  _SCALE = 1_000_000_000
1789
1846
 
1790
1847
 
@@ -2219,7 +2276,7 @@ def _svg_open(width, height, title, desc):
2219
2276
  f' <title>{_svg_escape(title)}</title>\n'
2220
2277
  f' <desc>{_svg_escape(desc)}</desc>\n'
2221
2278
  ' <defs>\n'
2222
- ' <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" '
2279
+ ' <marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" '
2223
2280
  'markerWidth="9" markerHeight="9" orient="auto" '
2224
2281
  'markerUnits="userSpaceOnUse">\n'
2225
2282
  ' <path d="M0 0 L10 5 L0 10 z" fill="black"/>\n'
@@ -2232,8 +2289,8 @@ def _svg_open(width, height, title, desc):
2232
2289
  def _svg_node_shape(kind, cx, cy, half_w):
2233
2290
  if kind == "folder":
2234
2291
  return (f' <rect x="{cx - half_w}" y="{cy - _GRAPH_NODE_HALF_H}" '
2235
- f'width="{2 * half_w}" height="{_GRAPH_NODE_H}" rx="6" '
2236
- 'fill="white" stroke="black"/>\n')
2292
+ f'width="{2 * half_w}" height="{_GRAPH_NODE_H}" '
2293
+ f'rx="{_GRAPH_CORNER_R}" fill="white" stroke="black"/>\n')
2237
2294
  return (f' <ellipse cx="{cx}" cy="{cy}" rx="{half_w}" '
2238
2295
  f'ry="{_GRAPH_NODE_HALF_H}" fill="white" stroke="black"/>\n')
2239
2296
 
@@ -2267,13 +2324,13 @@ def _svg_circular(out, view):
2267
2324
  parts = [_svg_open(width, height, title, desc)]
2268
2325
  pos = {}
2269
2326
  label_pos = {}
2270
- half_by_id = {}
2327
+ shape_by_id = {}
2271
2328
  for i, node in enumerate(out["nodes"]):
2272
2329
  cos_v, sin_v = _circle_cos_sin(n, i)
2273
2330
  x = cx + _scaled_to_int(radius * cos_v)
2274
2331
  y = cy + _scaled_to_int(radius * sin_v)
2275
2332
  pos[node["id"]] = (x, y)
2276
- half_by_id[node["id"]] = half_ws[i]
2333
+ shape_by_id[node["id"]] = (node["kind"], x, y, half_ws[i])
2277
2334
  # distance from the node center to its shape boundary along the
2278
2335
  # radial direction (support of the ellipse / rounded rect), plus a
2279
2336
  # small gap, keeps the label just outside its own node
@@ -2301,16 +2358,18 @@ def _svg_circular(out, view):
2301
2358
  c1y = y1 + (ty - y1) * 35 // 100
2302
2359
  c2x = x2 + (tx - x2) * 35 // 100
2303
2360
  c2y = y2 + (ty - y2) * 35 // 100
2304
- # stop the visible end just outside the target node shape
2305
- dx = x2 - c2x
2306
- dy = y2 - c2y
2307
- pull = half_by_id[e["to"]] + 9
2308
- length = max(1, isqrt(dx * dx + dy * dy))
2309
- end_x = x2 - dx * pull // length
2310
- end_y = y2 - dy * pull // length
2361
+ # the edge starts on the source boundary along its departure
2362
+ # tangent and ends on the target boundary along its arrival
2363
+ # tangent, so the arrowhead touches the target node
2364
+ skind, sx0, sy0, shw = shape_by_id[e["from"]]
2365
+ start_x, start_y = _shape_boundary(skind, sx0, sy0, shw,
2366
+ c1x - x1, c1y - y1)
2367
+ tkind, tx0, ty0, thw = shape_by_id[e["to"]]
2368
+ end_x, end_y = _shape_boundary(tkind, tx0, ty0, thw,
2369
+ c2x - x2, c2y - y2)
2311
2370
  parts.append(
2312
- f' <path d="M{x1} {y1} C{c1x} {c1y} {c2x} {c2y} {end_x} '
2313
- f'{end_y}" fill="none" stroke="black" '
2371
+ f' <path d="M{start_x} {start_y} C{c1x} {c1y} {c2x} {c2y} '
2372
+ f'{end_x} {end_y}" fill="none" stroke="black" '
2314
2373
  f'stroke-width="{1 + min(e["links"] - 1, 3)}" '
2315
2374
  'marker-end="url(#arrow)"/>\n')
2316
2375
  for i, node in enumerate(out["nodes"]):
@@ -3162,12 +3221,6 @@ def main(argv=None) -> int:
3162
3221
  v = need_value(args, flag)
3163
3222
  return v if v is not None else default
3164
3223
 
3165
- fmt = opt_value(rest, "--format", "text")
3166
- if cmd not in ("graph", "plan") and fmt not in ("text", "json"):
3167
- data = _error_dict(cmd, "invalid_option")
3168
- _emit(data, "json", None)
3169
- return 2
3170
-
3171
3224
  def _emit(data, fmt, text_fn):
3172
3225
  """Print the result (or a closed-vocabulary error) in the requested format."""
3173
3226
  if data.get("error"):
@@ -3182,6 +3235,12 @@ def main(argv=None) -> int:
3182
3235
  else:
3183
3236
  _write_out(text_fn(data).encode("utf-8"))
3184
3237
 
3238
+ fmt = opt_value(rest, "--format", "text")
3239
+ if cmd not in ("graph", "plan") and fmt not in ("text", "json"):
3240
+ data = _error_dict(cmd, "invalid_option")
3241
+ _emit(data, "json", None)
3242
+ return 2
3243
+
3185
3244
  if cmd == "index":
3186
3245
  cleaned = []
3187
3246
  skip_next = False
@@ -1,4 +1,4 @@
1
- """Sieve Notes 0.3.0 — acceptance tests for observation, block trees,
1
+ """Sieve Notes 0.3.1 — acceptance tests for observation, block trees,
2
2
  conversion, and the graph and plan commands.
3
3
 
4
4
  Conventions:
@@ -10,6 +10,7 @@ Conventions:
10
10
 
11
11
  import hashlib
12
12
  import inspect
13
+ import math
13
14
  import json
14
15
  import os
15
16
  import re
@@ -32,10 +33,10 @@ CLI = [sys.executable, str(REPO / "sieve_notes.py")]
32
33
  EX_VAULTS = REPO / "examples"
33
34
 
34
35
  # sha256 of the SVG files built from `examples/vault_wikilink` (measured on
35
- # the 0.3.0 tree; NT-T30 compares freshly built files against them).
36
- GOLDEN_SVG_LINKS = "eb5bac34e574cdeaeee5e9d081a37b23dab106b5afff72404d59d1c3da31aa72"
37
- GOLDEN_SVG_FOLDERS = "84170a30bcbb6a98b31e6f26e4ddc1c26a44504238ee2d83647b108eabb5a8dc"
38
- GOLDEN_SVG_TREE = "2177e5c93c2cbdf4cb96ac8a6aac3320455d3b80caaa1ed6270a0b9435bc1bba"
36
+ # the current tree; NT-T30 compares freshly built files against them).
37
+ GOLDEN_SVG_LINKS = "b68f628179124e614b0a71f8b02a0e8ccd0b900d33995fbf160a3ab7704b21bc"
38
+ GOLDEN_SVG_FOLDERS = "ab7148d7f6654e00174f38d4c753ec1f2a9d9bc91f24de7e4137710f3318b7ef"
39
+ GOLDEN_SVG_TREE = "7c1e6cc86c6c1a9aaec1b145c14359705c5fcffc00c6d73e4fb5927f7eeaeab4"
39
40
 
40
41
 
41
42
  def _tag(element):
@@ -905,7 +906,7 @@ class NT_T14_PackagingZeroDeps(unittest.TestCase):
905
906
  if n.endswith(".dist-info/METADATA")][0]
906
907
  meta = zf.read(meta_name).decode("utf-8")
907
908
  self.assertIn("Name: sieve-notes", meta)
908
- self.assertIn("Version: 0.3.0", meta)
909
+ self.assertIn("Version: 0.3.1", meta)
909
910
  self.assertIn("License-Expression: MIT", meta)
910
911
  self.assertNotIn("Requires-Dist:", meta)
911
912
  with tempfile.TemporaryDirectory() as vd:
@@ -938,11 +939,11 @@ class NT_T15_VersionDocsPublicTextAndRelease(unittest.TestCase):
938
939
  """Version, README, docs, public text check and the structure of release.yml."""
939
940
 
940
941
  def test_version_pins_agree(self):
941
- self.assertEqual(sieve_notes.__version__, "0.3.0")
942
+ self.assertEqual(sieve_notes.__version__, "0.3.1")
942
943
  pyproject = (REPO / "pyproject.toml").read_text(encoding="utf-8")
943
- self.assertIn('version = "0.3.0"', pyproject)
944
+ self.assertIn('version = "0.3.1"', pyproject)
944
945
  changelog = (REPO / "CHANGELOG.md").read_text(encoding="utf-8")
945
- self.assertTrue(changelog.startswith("## [0.3.0]"))
946
+ self.assertTrue(changelog.startswith("## [0.3.1]"))
946
947
 
947
948
  def test_public_text_checker_clean_zero_findings(self):
948
949
  proc = subprocess.run(
@@ -1013,15 +1014,15 @@ class NT_T15_VersionDocsPublicTextAndRelease(unittest.TestCase):
1013
1014
  root = Path(td)
1014
1015
  (root / "release-assets").mkdir()
1015
1016
  assets = root / "release-assets"
1016
- (assets / "sieve_notes-0.3.0-py3-none-any.whl").write_bytes(b"w")
1017
- (assets / "sieve_notes-0.3.0.tar.gz").write_bytes(b"s")
1017
+ (assets / "sieve_notes-0.3.1-py3-none-any.whl").write_bytes(b"w")
1018
+ (assets / "sieve_notes-0.3.1.tar.gz").write_bytes(b"s")
1018
1019
  (assets / "SHA256SUMS.txt").write_bytes(b"sums\n")
1019
1020
  proc = subprocess.run(
1020
1021
  [sys.executable, str(tool),
1021
1022
  "--assets-dir", str(assets)],
1022
1023
  capture_output=True, encoding="utf-8")
1023
1024
  self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
1024
- (assets / "sieve_notes-0.3.0-py3-none-any.whl").unlink()
1025
+ (assets / "sieve_notes-0.3.1-py3-none-any.whl").unlink()
1025
1026
  proc = subprocess.run(
1026
1027
  [sys.executable, str(tool),
1027
1028
  "--assets-dir", str(assets)],
@@ -1032,7 +1033,7 @@ class NT_T15_VersionDocsPublicTextAndRelease(unittest.TestCase):
1032
1033
  root = Path(td)
1033
1034
  assets = root / "release-assets"
1034
1035
  assets.mkdir()
1035
- (assets / "sieve_notes-0.3.0.tar.gz").write_bytes(b"s")
1036
+ (assets / "sieve_notes-0.3.1.tar.gz").write_bytes(b"s")
1036
1037
  proc = subprocess.run(
1037
1038
  [sys.executable, str(tool),
1038
1039
  "--assets-dir", str(assets)],
@@ -1053,22 +1054,22 @@ class NT_T15_VersionDocsPublicTextAndRelease(unittest.TestCase):
1053
1054
 
1054
1055
  with tempfile.TemporaryDirectory() as td:
1055
1056
  listing = Path(td) / "releases.json"
1056
- assets = [{"name": "sieve_notes-0.3.0-py3-none-any.whl"},
1057
- {"name": "sieve_notes-0.3.0.tar.gz"},
1057
+ assets = [{"name": "sieve_notes-0.3.1-py3-none-any.whl"},
1058
+ {"name": "sieve_notes-0.3.1.tar.gz"},
1058
1059
  {"name": "SHA256SUMS.txt"}]
1059
1060
  listing.write_text(json.dumps(
1060
- [{"tag_name": "v0.3.0", "draft": True,
1061
+ [{"tag_name": "v0.3.1", "draft": True,
1061
1062
  "assets": assets}]), encoding="utf-8")
1062
- proc = run_check(listing, "v0.3.0")
1063
+ proc = run_check(listing, "v0.3.1")
1063
1064
  self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
1064
1065
  listing.write_text(json.dumps(
1065
- [{"tag_name": "v0.3.0", "draft": True,
1066
+ [{"tag_name": "v0.3.1", "draft": True,
1066
1067
  "assets": assets[1:]}]), encoding="utf-8")
1067
- self.assertEqual(run_check(listing, "v0.3.0").returncode, 1)
1068
+ self.assertEqual(run_check(listing, "v0.3.1").returncode, 1)
1068
1069
  listing.write_text(json.dumps(
1069
- [{"tag_name": "v0.3.0", "draft": False,
1070
+ [{"tag_name": "v0.3.1", "draft": False,
1070
1071
  "assets": assets}]), encoding="utf-8")
1071
- self.assertEqual(run_check(listing, "v0.3.0").returncode, 1)
1072
+ self.assertEqual(run_check(listing, "v0.3.1").returncode, 1)
1072
1073
  self.assertEqual(run_check(listing, "v9.9.9").returncode, 1)
1073
1074
 
1074
1075
 
@@ -1690,14 +1691,14 @@ class NT_T23_MathDoesNotAffectWordsOrStrict(unittest.TestCase):
1690
1691
 
1691
1692
 
1692
1693
  class NT_T24_VersionChangelogDocsMath(unittest.TestCase):
1693
- """Version 0.3.0 and the CHANGELOG section (3-5 user-facing items).
1694
+ """Version 0.3.1 and the CHANGELOG section (3-5 user-facing items).
1694
1695
  The README and docs descriptions of math are pinned in the docs commit
1695
1696
  (the tests ride with the files they describe)."""
1696
1697
 
1697
1698
  def test_version_pins_agree(self):
1698
- self.assertEqual(sieve_notes.__version__, "0.3.0")
1699
+ self.assertEqual(sieve_notes.__version__, "0.3.1")
1699
1700
  pyproject = (REPO / "pyproject.toml").read_text(encoding="utf-8")
1700
- self.assertIn('version = "0.3.0"', pyproject)
1701
+ self.assertIn('version = "0.3.1"', pyproject)
1701
1702
 
1702
1703
  def test_changelog_newest_section_has_three_to_five_items(self):
1703
1704
  changelog = (REPO / "CHANGELOG.md").read_text(encoding="utf-8")
@@ -1714,8 +1715,8 @@ class NT_T24_VersionChangelogDocsMath(unittest.TestCase):
1714
1715
  self.assertNotIn("- Tags\n", en)
1715
1716
  self.assertIn("- 数式(インライン `$…$`、表示 `$$…$$`)", ja)
1716
1717
  self.assertNotIn("- タグ\n", ja)
1717
- self.assertEqual(en.count("# Sieve Notes v0.3.0"), 1)
1718
- self.assertEqual(ja.count("# Sieve Notes v0.3.0"), 1)
1718
+ self.assertEqual(en.count("# Sieve Notes v0.3.1"), 1)
1719
+ self.assertEqual(ja.count("# Sieve Notes v0.3.1"), 1)
1719
1720
 
1720
1721
  def test_docs_describe_math_and_drop_tags(self):
1721
1722
  formats = (REPO / "docs" / "formats.md").read_text(encoding="utf-8")
@@ -2935,16 +2936,16 @@ class NT_T39_ExistingOutputsUnchanged(unittest.TestCase):
2935
2936
 
2936
2937
 
2937
2938
  class NT_T40_VersionDocsVocabularyAndReadme(unittest.TestCase):
2938
- """Version 0.3.0, the CHANGELOG section, the docs and README carry the
2939
+ """Version 0.3.1, the CHANGELOG section, the docs and README carry the
2939
2940
  new commands and words, the examples match the real output and the
2940
2941
  vocabulary document agrees with the implementation."""
2941
2942
 
2942
2943
  def test_version_pins_agree(self):
2943
- self.assertEqual(sieve_notes.__version__, "0.3.0")
2944
+ self.assertEqual(sieve_notes.__version__, "0.3.1")
2944
2945
  pyproject = (REPO / "pyproject.toml").read_text(encoding="utf-8")
2945
- self.assertIn('version = "0.3.0"', pyproject)
2946
+ self.assertIn('version = "0.3.1"', pyproject)
2946
2947
  changelog = (REPO / "CHANGELOG.md").read_text(encoding="utf-8")
2947
- self.assertTrue(changelog.startswith("## [0.3.0]"))
2948
+ self.assertTrue(changelog.startswith("## [0.3.1]"))
2948
2949
 
2949
2950
  def test_closed_word_lists_in_the_implementation(self):
2950
2951
  self.assertEqual(sieve_notes.GRAPH_VIEWS, ("links", "folders", "tree"))
@@ -2968,7 +2969,7 @@ class NT_T40_VersionDocsVocabularyAndReadme(unittest.TestCase):
2968
2969
  items = [l for l in section.split("\n") if l.startswith("- ")]
2969
2970
  self.assertTrue(3 <= len(items) <= 5)
2970
2971
  self.assertIn("`graph`", section)
2971
- self.assertIn("`plan`", section)
2972
+ self.assertIn("`plan`", changelog) # plan rides in its 0.3.0 section
2972
2973
  lowered = section.lower()
2973
2974
  for word in ("unittest", "mbox", " ci ", "release.yml"):
2974
2975
  self.assertNotIn(word, lowered)
@@ -3000,8 +3001,8 @@ class NT_T40_VersionDocsVocabularyAndReadme(unittest.TestCase):
3000
3001
  def test_readme_example_outputs_match_the_real_output(self):
3001
3002
  en = (REPO / "README.md").read_text(encoding="utf-8")
3002
3003
  ja = (REPO / "README.ja.md").read_text(encoding="utf-8")
3003
- self.assertEqual(en.count("# Sieve Notes v0.3.0"), 1)
3004
- self.assertEqual(ja.count("# Sieve Notes v0.3.0"), 1)
3004
+ self.assertEqual(en.count("# Sieve Notes v0.3.1"), 1)
3005
+ self.assertEqual(ja.count("# Sieve Notes v0.3.1"), 1)
3005
3006
  for text in (en, ja):
3006
3007
  self.assertIn("sieve-notes graph", text)
3007
3008
  self.assertIn("sieve-notes plan", text)
@@ -3021,5 +3022,196 @@ class NT_T40_VersionDocsVocabularyAndReadme(unittest.TestCase):
3021
3022
  if _tag(e) in ("ellipse", "rect")]
3022
3023
  self.assertGreaterEqual(len(shapes), 3)
3023
3024
 
3025
+ # --------------------------------------------------------------- 0.3.1: acceptance fixes
3026
+
3027
+
3028
+ class NT_T41_SvgEdgeEndpointsOnNodeBoundaries(unittest.TestCase):
3029
+ """Every SVG edge starts on the boundary of its source node and ends on
3030
+ the boundary of its target node (within one pixel), so the arrowhead
3031
+ touches the target node. Measured by parsing the SVG."""
3032
+
3033
+ def _svg_geometry(self, text):
3034
+ """Node shapes (id -> geometry) and the edge endpoints of the SVG."""
3035
+ root = _parse_svg(text)
3036
+ shapes = {}
3037
+ for g in root.iter():
3038
+ if _tag(g) != "g" or g.get("id") is None:
3039
+ continue
3040
+ for e in g.iter():
3041
+ tag = _tag(e)
3042
+ if tag == "ellipse":
3043
+ shapes[g.get("id")] = ("ellipse",
3044
+ (float(e.get("cx")),
3045
+ float(e.get("cy"))),
3046
+ float(e.get("rx")),
3047
+ float(e.get("ry")))
3048
+ elif tag == "rect":
3049
+ shapes[g.get("id")] = ("rect",
3050
+ (float(e.get("x")),
3051
+ float(e.get("y"))),
3052
+ float(e.get("width")),
3053
+ float(e.get("height")),
3054
+ float(e.get("rx")))
3055
+ edges = []
3056
+ for e in root.iter():
3057
+ if _tag(e) == "path" and e.get("marker-end"):
3058
+ nums = re.findall(r"-?\d+", e.get("d"))
3059
+ start = (float(nums[0]), float(nums[1]))
3060
+ end = (float(nums[-2]), float(nums[-1]))
3061
+ edges.append((start, end))
3062
+ markers = [e.get("refX") for e in root.iter() if _tag(e) == "marker"]
3063
+ return shapes, edges, markers
3064
+
3065
+ def _dist(self, shape, px, py):
3066
+ kind = shape[0]
3067
+ if kind == "ellipse":
3068
+ (cx, cy), rx, ry = shape[1], shape[2], shape[3]
3069
+ else:
3070
+ (x, y), w, h, cr = shape[1], shape[2], shape[3], shape[4]
3071
+ cx, cy = x + w / 2, y + h / 2
3072
+ rx, ry = w / 2, h / 2
3073
+ dx, dy = px - cx, py - cy
3074
+ norm = math.hypot(dx, dy)
3075
+ if norm < 1e-9:
3076
+ return min(rx, ry)
3077
+ ux, uy = dx / norm, dy / norm
3078
+ if kind == "ellipse":
3079
+ t_boundary = 1.0 / math.hypot(ux / rx, uy / ry)
3080
+ return abs(norm - t_boundary)
3081
+ # rounded rectangle: the nearest of the four edges and the four
3082
+ # corner arcs is the honest boundary distance
3083
+ corners = [(cx + math.copysign(rx - cr, ux or 1),
3084
+ cy + math.copysign(ry - cr, uy or 1))]
3085
+ best = None
3086
+ # straight edges
3087
+ tx = rx / abs(ux) if abs(ux) > 1e-12 else float("inf")
3088
+ ty = ry / abs(uy) if abs(uy) > 1e-12 else float("inf")
3089
+ t_edge = min(tx, ty)
3090
+ if t_edge < float("inf"):
3091
+ bx, by = cx + t_edge * ux, cy + t_edge * uy
3092
+ in_corner = (abs(bx - cx) >= rx - cr - 1e-9 and
3093
+ abs(by - cy) >= ry - cr - 1e-9)
3094
+ if not in_corner:
3095
+ cand = math.hypot(px - bx, py - by)
3096
+ best = cand if best is None else min(best, cand)
3097
+ # corner arcs
3098
+ for kx, ky in corners:
3099
+ fx, fy = cx - kx, cy - ky
3100
+ bq = 2 * (fx * ux + fy * uy)
3101
+ c0 = fx * fx + fy * fy - cr * cr
3102
+ disc = bq * bq - 4 * c0
3103
+ if disc >= 0:
3104
+ sd = math.sqrt(disc)
3105
+ for root_t in ((-bq - sd) / 2, (-bq + sd) / 2):
3106
+ if root_t > 1e-9:
3107
+ bx, by = cx + root_t * ux, cy + root_t * uy
3108
+ cand = math.hypot(px - bx, py - by)
3109
+ best = cand if best is None else min(best, cand)
3110
+ if best is None:
3111
+ bx, by = cx + t_edge * ux, cy + t_edge * uy
3112
+ best = math.hypot(px - bx, py - by)
3113
+ return best
3114
+
3115
+ def _check_vault(self, vault, views=("links", "folders")):
3116
+ for view in views:
3117
+ proc, data = jrun(["graph", str(vault), "--view", view,
3118
+ "--format", "json"])
3119
+ self.assertEqual(proc.returncode, 0, proc.stdout)
3120
+ svg = run_cli(["graph", str(vault), "--view", view,
3121
+ "--format", "svg"]).stdout
3122
+ shapes, edges, markers = self._svg_geometry(svg)
3123
+ self.assertEqual(len(edges), len(data["edges"]), view)
3124
+ self.assertEqual(markers, ["10"], view)
3125
+ self.assertEqual(len(shapes), len(data["nodes"]), view)
3126
+ for e, (start, end) in zip(data["edges"], edges):
3127
+ d_start = self._dist(shapes[e["from"]], *start)
3128
+ d_end = self._dist(shapes[e["to"]], *end)
3129
+ self.assertLessEqual(d_start, 1.0,
3130
+ f"{view} start {e} at {start}: {d_start}")
3131
+ self.assertLessEqual(d_end, 1.0,
3132
+ f"{view} end {e} at {end}: {d_end}")
3133
+
3134
+ def test_vault_wikilink_links_and_folders(self):
3135
+ self._check_vault(EX_VAULTS / "vault_wikilink")
3136
+
3137
+ def test_dense_vault_with_mutual_links(self):
3138
+ with tempfile.TemporaryDirectory() as td:
3139
+ root = Path(td)
3140
+ names = [f"note{i:02d}" for i in range(12)]
3141
+ files = {}
3142
+ for i, name in enumerate(names):
3143
+ nxt = names[(i + 1) % len(names)]
3144
+ lines = [f"[[{nxt}]]"]
3145
+ if i != 0:
3146
+ lines.append("[[note00]]")
3147
+ files[f"d{i % 3}/{name}.md"] = f"# {name}\n" + \
3148
+ "\n".join(lines) + "\n"
3149
+ write_vault(root, files)
3150
+ self._check_vault(root)
3151
+ # the ring plus the links to note00 really give many edges
3152
+ proc, data = jrun(["graph", str(root), "--format", "json"])
3153
+ self.assertGreaterEqual(data["totals"]["nodes"], 12)
3154
+ self.assertGreaterEqual(data["totals"]["edges"], 20)
3155
+
3156
+
3157
+ class NT_T42_UnknownFormatIsInvalidOption(unittest.TestCase):
3158
+ """An unknown --format for index, blocks and convert exits 2 with the
3159
+ closed error word (the valid outputs are unchanged; NT-T39 pins them)."""
3160
+
3161
+ def test_unknown_format_error(self):
3162
+ with tempfile.TemporaryDirectory() as td:
3163
+ root = Path(td)
3164
+ write_vault(root, {"a.md": "# a\n"})
3165
+ out = Path(td) / "out.md"
3166
+ cases = [
3167
+ (["index", td], "index"),
3168
+ (["blocks", str(root / "a.md")], "blocks"),
3169
+ (["convert", str(root / "a.md"), "--to", "outline",
3170
+ "-o", str(out)], "convert"),
3171
+ ]
3172
+ for args, cmd in cases:
3173
+ for fmt in ("yaml", "png", "XML", ""):
3174
+ proc = run_cli(args + ["--format", fmt])
3175
+ self.assertEqual(proc.returncode, 2, (cmd, fmt))
3176
+ data = json.loads(proc.stdout)
3177
+ self.assertEqual(data, {"notes_version": 1,
3178
+ "command": cmd,
3179
+ "error": "invalid_option",
3180
+ "exit_code": 2}, (cmd, fmt))
3181
+ self.assertFalse(out.exists(), "convert wrote nothing on the error")
3182
+
3183
+ def test_known_formats_still_work(self):
3184
+ with tempfile.TemporaryDirectory() as td:
3185
+ root = Path(td)
3186
+ write_vault(root, {"a.md": "# a\n[[b]]\n", "b.md": "# b\n"})
3187
+ for fmt in ("text", "json"):
3188
+ proc = run_cli(["index", td, "--format", fmt])
3189
+ self.assertEqual(proc.returncode, 0, proc.stdout)
3190
+ self.assertTrue(proc.stdout, fmt)
3191
+
3192
+
3193
+ class NT_T43_DocVersionsMatchPyproject(unittest.TestCase):
3194
+ """The version statements in the docs agree with pyproject.toml, and the
3195
+ workflow reads the version from pyproject.toml instead of repeating it."""
3196
+
3197
+ def test_doc_version_statements_match_pyproject(self):
3198
+ pyproject = (REPO / "pyproject.toml").read_text(encoding="utf-8")
3199
+ version = re.search(r'(?m)^version = "([^"]+)"', pyproject).group(1)
3200
+ self.assertEqual(version, sieve_notes.__version__)
3201
+ for doc in sorted((REPO / "docs").glob("*.md")):
3202
+ text = doc.read_text(encoding="utf-8")
3203
+ for m in re.finditer(r"Sieve Notes (\d+\.\d+\.\d+)", text):
3204
+ self.assertEqual(m.group(1), version,
3205
+ f"{doc.name}: {m.group(0)}")
3206
+
3207
+ def test_workflow_reads_the_version_from_pyproject(self):
3208
+ if not (REPO / ".github" / "workflows").is_dir():
3209
+ self.skipTest(NO_WORKFLOWS)
3210
+ text = (REPO / ".github" / "workflows" / "test.yml").read_text(
3211
+ encoding="utf-8")
3212
+ self.assertNotIn("sieve_notes-0.", text,
3213
+ "artifact names are not hardcoded")
3214
+ self.assertIn("pyproject.toml", text)
3215
+
3024
3216
  if __name__ == "__main__":
3025
3217
  unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes