path_coverage 0.1.0 → 0.3.0

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +315 -107
  3. data/lib/path_coverage/calls.rb +55 -23
  4. data/lib/path_coverage/card.rb +14 -0
  5. data/lib/path_coverage/condition.rb +33 -3
  6. data/lib/path_coverage/configuration.rb +43 -22
  7. data/lib/path_coverage/configuration_paths.rb +58 -0
  8. data/lib/path_coverage/console_summary.rb +75 -0
  9. data/lib/path_coverage/gaps.rb +32 -13
  10. data/lib/path_coverage/html/file.html +5 -5
  11. data/lib/path_coverage/html/index.html +6 -18
  12. data/lib/path_coverage/html/settings.js +50 -0
  13. data/lib/path_coverage/html/side.js +341 -413
  14. data/lib/path_coverage/html/sort.js +24 -21
  15. data/lib/path_coverage/html/style.css +339 -207
  16. data/lib/path_coverage/html/tabs.js +15 -0
  17. data/lib/path_coverage/html/theme.js +27 -0
  18. data/lib/path_coverage/html_branch.rb +30 -0
  19. data/lib/path_coverage/html_cards.rb +111 -0
  20. data/lib/path_coverage/html_cells.rb +66 -0
  21. data/lib/path_coverage/html_file.rb +82 -68
  22. data/lib/path_coverage/html_index.rb +95 -41
  23. data/lib/path_coverage/html_index_head.rb +29 -0
  24. data/lib/path_coverage/html_labels.rb +23 -0
  25. data/lib/path_coverage/html_methods.rb +66 -0
  26. data/lib/path_coverage/html_nav.rb +50 -50
  27. data/lib/path_coverage/html_report.rb +69 -56
  28. data/lib/path_coverage/html_statements.rb +166 -0
  29. data/lib/path_coverage/html_syntax.rb +156 -0
  30. data/lib/path_coverage/html_tabs.rb +26 -0
  31. data/lib/path_coverage/html_template.rb +6 -0
  32. data/lib/path_coverage/html_tree.rb +59 -74
  33. data/lib/path_coverage/json_reader.rb +101 -0
  34. data/lib/path_coverage/json_writer.rb +52 -7
  35. data/lib/path_coverage/kernel.rb +55 -53
  36. data/lib/path_coverage/kinds/base.rb +71 -0
  37. data/lib/path_coverage/kinds/block.rb +137 -0
  38. data/lib/path_coverage/kinds/case.rb +92 -0
  39. data/lib/path_coverage/kinds/chain.rb +45 -0
  40. data/lib/path_coverage/kinds/choice.rb +68 -0
  41. data/lib/path_coverage/kinds/contains.rb +113 -0
  42. data/lib/path_coverage/kinds/safe.rb +153 -0
  43. data/lib/path_coverage/kinds/write.rb +54 -0
  44. data/lib/path_coverage/kinds.rb +37 -0
  45. data/lib/path_coverage/manifest.rb +60 -20
  46. data/lib/path_coverage/manifest_blocks.rb +48 -10
  47. data/lib/path_coverage/manifest_case.rb +2 -3
  48. data/lib/path_coverage/manifest_chains.rb +76 -0
  49. data/lib/path_coverage/manifest_choices.rb +32 -18
  50. data/lib/path_coverage/manifest_folding.rb +91 -0
  51. data/lib/path_coverage/manifest_ignoring.rb +35 -0
  52. data/lib/path_coverage/manifest_writes.rb +67 -0
  53. data/lib/path_coverage/merge.rb +19 -3
  54. data/lib/path_coverage/method_statements.rb +300 -0
  55. data/lib/path_coverage/post.rb +8 -8
  56. data/lib/path_coverage/recorder.rb +20 -79
  57. data/lib/path_coverage/recorder_blocks.rb +68 -0
  58. data/lib/path_coverage/recorder_cases.rb +23 -0
  59. data/lib/path_coverage/recorder_chains.rb +40 -0
  60. data/lib/path_coverage/recorder_writes.rb +26 -0
  61. data/lib/path_coverage/render.rb +56 -47
  62. data/lib/path_coverage/result.rb +19 -0
  63. data/lib/path_coverage/rewriter.rb +69 -107
  64. data/lib/path_coverage/rewriter_nested.rb +62 -0
  65. data/lib/path_coverage/site_paths.rb +9 -58
  66. data/lib/path_coverage/site_tree.rb +21 -57
  67. data/lib/path_coverage/statement_arms.rb +161 -0
  68. data/lib/path_coverage/summary.rb +41 -17
  69. data/lib/path_coverage/totals.rb +6 -12
  70. data/lib/path_coverage/version.rb +1 -1
  71. data/lib/path_coverage/within_methods.rb +92 -0
  72. metadata +40 -11
  73. data/lib/path_coverage/html/toggle.js +0 -12
  74. data/lib/path_coverage/html_paths.rb +0 -138
  75. data/lib/path_coverage/path_gaps.rb +0 -41
  76. data/lib/path_coverage/path_manifest.rb +0 -110
@@ -9,37 +9,68 @@
9
9
  --rule: #D5DAE2;
10
10
  --ok: #1F5FBF;
11
11
  --ok-tint: #E6EEFA;
12
- --warn: #A35200;
13
12
  --bad: #B54708;
14
13
  --on-status: #FFFFFF;
15
14
  --link: #1F5FBF;
16
- /* The tree is inverted from the page, so it never reads as
17
- more source lines. */
18
- --tree-bg: #1E2638;
19
- --tree-fg: #E8ECF4;
20
- --tree-muted: #A3AEC2;
21
- --tree-rule: #3A4560;
22
- --tree-gap: #F5A25D;
23
15
  --font-body: "Helvetica Neue", Arial, sans-serif;
24
16
  --font-code: Menlo, Consolas, "DejaVu Sans Mono", monospace;
25
17
  }
26
- @media (prefers-color-scheme: dark) {
27
- :root {
28
- --bg: #12151C; --surface: #181C25; --panel: #212633; --fg: #E4E8EF;
29
- --muted: #9AA4B5; --rule: #323949; --ok: #7FB0FF; --ok-tint: #1A2740;
30
- --warn: #F0A35E; --bad: #F08A3C; --on-status: #12151C; --link: #7FB0FF;
31
- --tree-bg: #E6EAF2; --tree-fg: #1C2230; --tree-muted: #4E5869;
32
- --tree-rule: #BCC4D2; --tree-gap: #A8480A;
33
- color-scheme: dark;
34
- }
18
+ /* Dark, unless the page's html element names light, as the theme
19
+ button does when pressed; so a page draws dark before any script
20
+ runs. */
21
+ :root:not([data-theme="light"]) {
22
+ --bg: #12151C; --surface: #181C25; --panel: #212633; --fg: #E4E8EF;
23
+ --muted: #9AA4B5; --rule: #323949; --ok: #7FB0FF; --ok-tint: #1A2740;
24
+ --bad: #F08A3C; --on-status: #12151C; --link: #7FB0FF;
25
+ --syn-k: #C79BEA; --syn-s: #9CCB9E; --syn-c: #7F8A99;
26
+ --syn-n: #E9A3C9; --syn-t: #AEB5F5; --syn-v: #7FCFC4; --syn-o: #E6D27A;
27
+ color-scheme: dark;
35
28
  }
29
+ /* Code's syntax colours, each muted so the orange, blue and green
30
+ of coverage still stand out: keywords, strings, comments,
31
+ numbers, constants, instance variables, and, in bold gold, the
32
+ operators that decide a path, eg && and &. */
33
+ :root {
34
+ --syn-k: #7E3BA0; --syn-s: #3B7550; --syn-c: #77808F;
35
+ --syn-n: #9E4A78; --syn-t: #4B52A0; --syn-v: #2A7570; --syn-o: #7A6600;
36
+ }
37
+ /* The same colours in the code and in a site's tree, its fold, and
38
+ a card's rows, which quote the code. */
39
+ :is(.src, .fold, .statements .prow) .k { color: var(--syn-k); }
40
+ :is(.src, .fold, .statements .prow) .s { color: var(--syn-s); }
41
+ :is(.src, .fold, .statements .prow) .c { color: var(--syn-c); font-style: italic; }
42
+ :is(.src, .fold, .statements .prow) .n { color: var(--syn-n); }
43
+ :is(.src, .fold, .statements .prow) .t { color: var(--syn-t); }
44
+ :is(.src, .fold, .statements .prow) .v { color: var(--syn-v); }
45
+ :is(.src, .fold, .statements .prow) .o { color: var(--syn-o); font-weight: 700; }
46
+ /* Everything a site's tree or a method's grid draws has this one
47
+ tint, in either mode; status is only ever the orange or blue of
48
+ an edge. A lit line, on a path being shown, is yellow. */
49
+ :root { --cond-tint: #E2F2D3; --lit: #FFE98A; }
50
+ :root:not([data-theme="light"]) { --cond-tint: #26361A; --lit: #5A4A12; }
51
+ /* --rail is the width of the column of trees and grids left of the
52
+ code; dragging the divider changes it. */
53
+ body { --rail: 560px; }
36
54
  body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 14px; }
37
55
  a { color: var(--link); }
38
56
  .page {
39
- max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px;
40
- padding: 40px max(16px, env(safe-area-inset-right, 0px)) 64px max(16px, env(safe-area-inset-left, 0px));
57
+ max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px;
58
+ padding: 0 max(16px, env(safe-area-inset-right, 0px)) 64px max(16px, env(safe-area-inset-left, 0px));
41
59
  }
60
+ /* A file's page is wider, to hold its rail beside its code. */
61
+ .page:has(.code) { max-width: 1800px; }
42
62
  h1 { margin: 0; font-size: 24px; font-weight: 600; }
63
+ /* Every page's top line: the Path coverage title, a link back to
64
+ the index on a file's page, then, on a file's page, its path. */
65
+ .top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
66
+ .title { margin: 0; font-size: 24px; font-weight: 600; }
67
+ .title a { color: inherit; text-decoration: none; }
68
+ .title a:hover { text-decoration: underline; }
69
+ /* A file's path links back to its row on the index, which stops
70
+ clear of the index's sticky header. */
71
+ h1.path a { color: inherit; text-decoration: none; }
72
+ h1.path a:hover { text-decoration: underline; }
73
+ table.files tr[id] { scroll-margin-top: 72px; }
43
74
  .box { border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); overflow-x: auto; }
44
75
  table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
45
76
  th, td { padding: 10px 16px; text-align: left; }
@@ -50,7 +81,22 @@ td:first-child { font-family: var(--font-code); }
50
81
  head, so it reads as a sum, not as one more file. */
51
82
  tfoot td { background: var(--panel); font-weight: 600; border-top: 1px solid var(--fg); }
52
83
  tfoot td:first-child { font-family: inherit; }
84
+ /* The index page's tabs, one per group of files; the selected
85
+ one framed as the table's headings are. */
86
+ .tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
87
+ .tabs [role="tab"] { font: inherit; font-size: 13px; padding: 6px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; }
88
+ .tabs [role="tab"][aria-selected="true"] { background: var(--panel); color: var(--fg); border-color: var(--fg); font-weight: 600; }
89
+ .tabs [role="tab"]:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
53
90
  .num, td:not(:first-child) { text-align: right; }
91
+ /* A total's taken, / of and % sit close, so a row still reads
92
+ 3 / 4 75%. The File column takes the table's spare width, so
93
+ it never spreads them apart. These rules name the files table,
94
+ so a path grid's taken cells are never matched. */
95
+ table.files tr > :first-child { width: 100%; }
96
+ table.files th, table.files td:not(:first-child) { white-space: nowrap; }
97
+ table.files .taken { text-align: right; padding-left: 32px; padding-right: 4px; }
98
+ table.files .of { text-align: left; padding-left: 0; padding-right: 6px; }
99
+ table.files .percent { text-align: right; padding-left: 6px; }
54
100
  th button {
55
101
  font: 600 13px var(--font-body); color: var(--fg); background: none; border: 0;
56
102
  padding: 4px 0; cursor: pointer;
@@ -63,16 +109,24 @@ th button:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
63
109
  /* A file's page: plain source; on lines holding a condition the
64
110
  line numbers are one button. Every number has the same box, so
65
111
  digits stay aligned whether or not they are on a button. */
66
- .back { margin: 0; font-size: 13px; }
67
112
  h1.path { font-family: var(--font-code); font-size: 18px; }
68
- /* The back link, path and site lists stick together as one
69
- header. */
113
+ /* The top line, and on a file's page its path and site lists,
114
+ stick together as one header. */
70
115
  .head {
71
116
  position: sticky; top: 0; z-index: 5;
72
117
  display: flex; flex-direction: column; gap: 10px;
73
118
  margin: 0 -16px; padding: 12px 16px; background: var(--bg);
74
119
  border-bottom: 1px solid var(--rule);
75
120
  }
121
+ /* The theme button, small, at the title bar's right end, showing
122
+ the theme it switches to: a moon for dark, a sun for light. */
123
+ .theme {
124
+ margin-left: auto; width: 30px; height: 30px; padding: 0; font-size: 16px; line-height: 1;
125
+ border: 1px solid var(--rule); border-radius: 6px; background: var(--surface);
126
+ color: var(--fg); cursor: pointer;
127
+ }
128
+ .theme:hover { background: var(--panel); }
129
+ .theme:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
76
130
  .jumps { display: flex; flex-direction: column; gap: 8px; }
77
131
  .jump-list { display: flex; gap: 6px; align-items: center; overflow-x: auto; white-space: nowrap; min-width: 0; }
78
132
  .jump-label { width: 64px; flex-shrink: 0; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
@@ -86,12 +140,20 @@ a.jump[data-status] { background: var(--cond-tint); border-right-color: transpar
86
140
  a.jump[data-status="covered"] { color: var(--ok); border-top-color: var(--ok); border-left-color: var(--ok); }
87
141
  a.jump[data-status="gaps"] { color: var(--bad); border-top-color: var(--bad); border-left-color: var(--bad); }
88
142
  a.jump:focus-visible, .nav a:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
89
- /* The source pane's border and background start after the nav
90
- column, so the arrows sit outside the pane yet scroll with
91
- their line. */
92
- .box:has(> .code) { position: relative; isolation: isolate; border: 0; background: none; border-radius: 0; }
143
+ /* The code sits right of the rail of cards. The rail's column is
144
+ always there, --rail wide, and the divider in the gap after it
145
+ drags to change that. */
146
+ .box:has(> .code) {
147
+ position: relative; isolation: isolate; border: 0; background: none; border-radius: 0;
148
+ display: grid; column-gap: 12px; grid-template-columns: var(--rail) minmax(0, 1fr);
149
+ }
150
+ .box > .rail { grid-column: 1; grid-row: 1; }
151
+ .box > .code { grid-column: 2; grid-row: 1; }
152
+ /* The source pane's border and background start after the rail,
153
+ the gap and the nav column, so the arrows sit outside the pane
154
+ yet scroll with their line. */
93
155
  .box:has(> .code)::before {
94
- content: ""; position: absolute; inset: 0 0 0 26px; z-index: -1;
156
+ content: ""; position: absolute; inset: 0 0 0 calc(var(--rail) + 38px); z-index: -1;
95
157
  border: 1px solid var(--rule); border-radius: 8px;
96
158
  background: var(--surface); pointer-events: none;
97
159
  }
@@ -99,29 +161,62 @@ a.jump:focus-visible, .nav a:focus-visible { outline: 3px solid var(--link); out
99
161
  tall, keeping the gutter narrow. */
100
162
  .nav { display: flex; flex-direction: column; justify-content: center; width: 26px; flex-shrink: 0; }
101
163
  .nav a { width: 22px; text-align: center; line-height: 14px; font-size: 12px; color: var(--bad); text-decoration: none; }
164
+ /* A covered card's arrows, between the covered cards' lines, are
165
+ blue, as their numbers are. */
166
+ .nav a[data-status="covered"] { color: var(--ok); }
102
167
  .nav a:hover { color: var(--fg); }
103
- /* Clears the sticky header when a link jumps to a line. */
104
- .lineno { scroll-margin-top: 190px; }
105
- button.lnum:has(.lineno:target) { outline: 3px solid var(--link); outline-offset: 1px; }
106
- .code { font-family: var(--font-code); font-size: 13px; line-height: 32px; padding: 10px 0; min-width: 720px; }
168
+ .nav a[data-prev]::before { content: "\25B2"; }
169
+ .nav a[data-next]::before { content: "\25BC"; }
170
+ /* Every row is as wide as the longest line (or the pane, if
171
+ wider), so a method's band, and a lit line, reach past the code
172
+ when it scrolls sideways. */
173
+ .code {
174
+ font-family: var(--font-code); font-size: 13px; line-height: 32px; padding: 10px 0;
175
+ position: relative; isolation: isolate; min-width: 0; overflow-x: auto;
176
+ display: grid; grid-template-columns: minmax(max-content, 1fr); align-content: start;
177
+ }
107
178
  .line, .block { display: flex; align-items: flex-start; }
179
+ /* A loose site's whole block, its lines' code included, opens its
180
+ top card. */
181
+ .block { cursor: pointer; border-radius: 6px; }
182
+ .block:hover { filter: brightness(0.97); }
183
+ .line:has(.lineno) { cursor: default; }
108
184
  .srcs { display: flex; flex-direction: column; }
185
+ .block .srcs { flex: 1; }
109
186
  .src { white-space: pre; }
187
+ /* A lit line's background spans the code pane's full width. */
188
+ .line .src { flex: 1; }
189
+ /* Each line's code is as tall as its row, even an empty line's, so
190
+ a method's stripe runs unbroken from row to row. */
191
+ .line > .src, .block > .srcs { align-self: stretch; }
192
+ .srcs > .src:last-child { flex-grow: 1; }
193
+ /* scroll-margin-top clears the sticky header when a link jumps to
194
+ a line. */
110
195
  .lineno {
111
196
  display: block; width: 52px; padding-right: 20px; text-align: right;
112
197
  color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0;
198
+ scroll-margin-top: 190px;
113
199
  }
200
+ /* A loose site's button, its 9px right margin included, takes the
201
+ 72px a plain number takes, so its lines' code starts where every
202
+ other line's does. Its 63px includes its borders, so at any zoom,
203
+ where a border is rounded to whole screen pixels, its width
204
+ holds. */
114
205
  button.lnum {
115
- display: flex; flex-direction: column; flex-shrink: 0; margin: 4px 8px 4px 0; padding: 0;
206
+ position: relative; display: flex; flex-direction: column; flex-shrink: 0;
207
+ box-sizing: border-box; width: 63px;
208
+ margin: 4px 9px 4px 0; padding: 0;
116
209
  border: 1px solid transparent; border-radius: 6px; cursor: pointer;
117
210
  font: 600 13px/24px var(--font-code); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
118
211
  }
119
- button.lnum { position: relative; }
212
+ /* A loose site's top card opens in the left rail: a closed button
213
+ points left, where its card will open; an open one has no arrow,
214
+ as a click leaves it open. */
120
215
  button.lnum::before {
121
- content: "\25B8"; position: absolute; left: 7px; top: 4px;
122
- font-size: 11px; line-height: 24px; transition: transform 120ms;
216
+ content: "\25C2"; position: absolute; left: 7px; top: 4px;
217
+ font-size: 11px; line-height: 24px;
123
218
  }
124
- button.lnum[aria-expanded="true"]::before { transform: rotate(90deg); }
219
+ button.lnum[aria-expanded="true"]::before { content: none; }
125
220
  /* With a site count the count and the triangle share the
126
221
  button's height, one 11px line each. */
127
222
  button.lnum:has(.site-count)::before { top: 12px; line-height: 11px; }
@@ -132,207 +227,244 @@ button.lnum:has(.lineno + .lineno)::before { top: auto; bottom: 2px; line-height
132
227
  position: absolute; left: 7px; top: 1px;
133
228
  font-size: 9px; line-height: 11px; font-weight: 700;
134
229
  }
135
- /* The rule between sites spans the tree's full width, through
136
- its 16px side padding. */
137
- .site + .site {
138
- border-top: 1px solid var(--tree-rule); margin: 6px -16px 0; padding: 6px 16px 0;
139
- }
140
230
  button.lnum .lineno { width: 50px; padding-right: 11px; color: inherit; line-height: 32px; margin: -4px 0; }
141
231
  /* A site's button wears the condition tint, edged in its
142
- status colour on the top and left only, as a method's bar is. */
232
+ status colour on the top and left only. */
143
233
  button.lnum[data-status] { box-shadow: none; background: var(--cond-tint); border-right-color: transparent; border-bottom-color: transparent; }
144
234
  button.lnum[data-status="covered"] { color: var(--ok); border-top-color: var(--ok); border-left-color: var(--ok); }
145
235
  button.lnum[data-status="gaps"] { color: var(--bad); border-top-color: var(--bad); border-left-color: var(--bad); }
146
236
  button.lnum:hover { filter: brightness(1.1); }
147
237
  button.lnum:focus-visible { outline: 3px solid var(--link); outline-offset: 1px; }
148
- .tree {
149
- margin: 4px 20px 12px 120px; padding: 10px 16px; border: 1px solid var(--tree-rule);
150
- border-radius: 8px; background: var(--tree-bg); color: var(--tree-fg); line-height: 30px;
151
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
152
- }
153
- /* A row is its branch and label, then one fixed-width column per
154
- path: flowing by column, each cell after the label takes the
155
- next path's column, however many paths the site has. */
156
- .row {
157
- display: grid; grid-template-columns: auto minmax(200px, 1fr);
158
- grid-auto-flow: column; grid-auto-columns: 32px; column-gap: 16px;
238
+ /* An open loose site has its button's status edges, top and left,
239
+ doubled to 2px. A jump to it opens its card, so its button has
240
+ no outline of the jump to it. */
241
+ button.lnum[aria-expanded="true"][data-status="gaps"] { box-shadow: inset 1px 1px 0 var(--bad); }
242
+ button.lnum[aria-expanded="true"][data-status="covered"] { box-shadow: inset 1px 1px 0 var(--ok); }
243
+ button.lnum:has(.lineno:target) { outline: none; }
244
+ /* While a card is open, no button keeps a focus outline. */
245
+ body[data-open] button.lnum:focus-visible { outline: none; }
246
+ .rail { position: relative; min-width: 0; }
247
+ /* Each row lays its branch and label out at their own width, the
248
+ label pushing its cells to the row's right edge, so a site's
249
+ cells line up in columns however long or deep its labels. */
250
+ .row { display: flex; align-items: center; gap: 8px; }
251
+ .row > :is(.text, .arm, .operator) { margin-right: auto; padding-right: 8px; }
252
+ /* An explicit width, not just a flex basis, so a row's natural
253
+ width counts each cell as 26px, not as its one letter. */
254
+ .row > :is(.cell, .count) { flex: none; width: 26px; }
255
+ /* A thin rule under each site's counts row, across the tree's
256
+ full width through its 16px side padding. */
257
+ .site > .row:first-child {
258
+ border-bottom: 1px solid var(--rule); margin: 0 -16px 6px; padding: 0 16px 4px;
159
259
  }
160
- .operator { grid-column: span 2; font-weight: 600; }
161
- .row[data-subtree] .operator { grid-column: auto; }
260
+ .operator { font-weight: 600; }
162
261
  .row .arm { white-space: pre; font-weight: 600; }
163
- .branch { white-space: pre; color: var(--tree-muted); margin-right: -16px; }
262
+ /* An if's then names its arm, quoting no code, so is italic. */
263
+ .row .arm[data-named] { font-style: italic; }
264
+ .branch { white-space: pre; color: var(--muted); margin-right: -16px; }
164
265
  .row .text { white-space: pre; }
165
- /* A branch glyph drawn as a cell a whole row tall: v a vertical
166
- line, t a vertical with a stub right, l the top half of a
167
- vertical with a stub right, h a horizontal, s nothing. */
266
+ /* A branch's cell, of the kind its data-bx names, drawn a whole
267
+ row tall so branches join from row to row: v a vertical line,
268
+ t a vertical with a stub right, l the top half of a vertical
269
+ with a stub right, h a horizontal, s nothing. */
168
270
  .bx { display: inline-block; width: 1ch; height: 30px; vertical-align: top; --stroke: linear-gradient(currentColor, currentColor); }
169
271
  .bx[data-bx="v"] { background: var(--stroke) 50% 0 / 1px 100% no-repeat; }
170
272
  .bx[data-bx="t"] { background: var(--stroke) 50% 0 / 1px 100% no-repeat, var(--stroke) 100% 50% / 50% 1px no-repeat; }
171
273
  .bx[data-bx="l"] { background: var(--stroke) 50% 0 / 1px 50% no-repeat, var(--stroke) 100% 50% / 50% 1px no-repeat; }
172
274
  .bx[data-bx="h"] { background: var(--stroke) 0 50% / 100% 1px no-repeat; }
173
- /* Each path's count heads its column, orange for a path never
174
- taken; a leaf's T or F on that path sits in a chip, as in a
175
- path grid, and a blank means the path never reached it. */
275
+ /* Each path heads its column with a snake, a vertical ~ standing
276
+ for the path below it, then 0, orange, for a path never taken,
277
+ or *, blue, for one taken, its count on hover; a leaf's T or F
278
+ on that path sits in a chip, as in a path grid, and a blank
279
+ means the path never reached it. */
176
280
  .row .count { text-align: center; font-variant-numeric: tabular-nums; color: var(--ok); font-weight: 600; }
177
- .row .count.never { color: var(--tree-gap); }
281
+ .row .count::before { content: "\2240"; }
282
+ .row .count.never { color: var(--bad); }
178
283
  .row .cell { text-align: center; }
179
- .row .cell:not(:empty) {
284
+ .row .cell:is(:not(:empty), [data-mark]) {
180
285
  align-self: center; line-height: 22px; border-radius: 3px;
181
286
  background: var(--surface); color: var(--fg); font: 600 12px var(--font-code);
182
287
  }
183
-
184
- /* SPIKE: the code and a rail share the box; each tree sits in
185
- the rail, level with its site (its top set by side.js). */
186
- body[data-layout="beside"] .page { max-width: 1800px; }
187
- /* The code sits between two rails, condition trees on the left
188
- and path grids on the right, each as wide as --cc-rail or
189
- --pc-rail. Both are 0 until one opens; registered, so they
190
- animate, sliding the code and its frame aside together. */
191
- @property --cc-rail { syntax: "<length>"; inherits: true; initial-value: 0px; }
192
- @property --pc-rail { syntax: "<length>"; inherits: true; initial-value: 0px; }
193
- body[data-layout="beside"] { transition: --cc-rail 250ms ease, --pc-rail 250ms ease; }
194
- body[data-open="cc"] { --cc-rail: 560px; }
195
- body[data-open="pc"] { --pc-rail: 560px; }
196
- body[data-layout="beside"] .box:has(> .code) {
197
- display: grid; column-gap: 12px;
198
- grid-template-columns: var(--cc-rail) minmax(0, 1fr) var(--pc-rail);
288
+ /* A cell's mark, drawn in place of a letter: a tick for a path
289
+ that took an arm or called its operand, a disc for a &.
290
+ receiver not nil, an empty set for one nil. */
291
+ .row .cell[data-mark="taken"]::before { content: "\2713"; }
292
+ .row .cell[data-mark="present"]::before { content: "\25CF"; }
293
+ .row .cell[data-mark="absent"]::before { content: "\2205"; }
294
+ /* Hovering a cell with hover text, eg a path's count or a &.
295
+ receiver's mark, shows that text in a chip above it. */
296
+ .row [data-hover] { position: relative; cursor: default; }
297
+ .row [data-hover]:hover::after {
298
+ content: attr(data-hover); position: absolute; bottom: 100%; left: 50%;
299
+ transform: translateX(-50%); z-index: 4; padding: 0 7px; border-radius: 4px;
300
+ white-space: nowrap; font: 700 11px/20px var(--font-body); background: var(--fg); color: var(--bg);
199
301
  }
200
- /* Every row is as wide as the longest line (or the pane, if
201
- wider), so a site's band and outline, and a lit line, reach
202
- past the code when it scrolls sideways. */
203
- body[data-layout="beside"] .code {
204
- min-width: 0; overflow-x: auto;
205
- display: grid; grid-template-columns: minmax(max-content, 1fr);
206
- }
207
- body[data-layout="beside"] .box:has(> .code)::before {
208
- left: calc(var(--cc-rail) + 38px); right: calc(var(--pc-rail) + 12px);
302
+
303
+ /* The divider: the gap between the rail and the code, a line down
304
+ its middle that darkens as it is hovered or dragged. */
305
+ .divider {
306
+ position: absolute; top: 0; bottom: 0; left: var(--rail); width: 12px;
307
+ cursor: col-resize; z-index: 4; touch-action: none;
209
308
  }
210
- .rail { position: relative; min-width: 0; }
211
- /* The rail's tree sits on the condition tint, in the page's own
212
- text colours, as a path grid sits on the path tint. */
213
- .rail .tree {
214
- --tree-bg: var(--cond-tint); --tree-fg: var(--fg); --tree-muted: var(--muted);
215
- --tree-rule: var(--rule); --tree-gap: var(--bad);
309
+ .divider::after {
310
+ content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px;
311
+ background: var(--rule);
216
312
  }
217
- /* The rail's tree has narrower columns, to fit its width; a
218
- thin rule under each site's counts row, across the tree's
219
- full width through its 16px side padding. */
220
- .rail .row { grid-template-columns: auto minmax(120px, 1fr); grid-auto-columns: 26px; column-gap: 8px; }
221
- .rail .site > .row:first-child {
222
- border-bottom: 1px solid var(--tree-rule); margin: 0 -16px 6px; padding: 0 16px 4px;
223
- }
224
- .rail .tree { position: absolute; left: 0; right: 0; margin: 0; z-index: 2; font-family: var(--font-code); font-size: 13px; }
225
- /* Beside, a site's whole block, its lines' code included, is
226
- tinted by status and opens its tree, so each tree lines up
227
- with a band the eye can follow across. */
228
- :root { --bad-tint: #FBE6D6; }
229
- @media (prefers-color-scheme: dark) { :root { --bad-tint: #3A2416; } }
230
- /* Everything a site's grid draws has this tint, as everything
231
- a method's grid draws has --path-tint; status is only ever
232
- the orange or blue of an edge. */
233
- :root { --cond-tint: #E2F2D3; }
234
- @media (prefers-color-scheme: dark) { :root { --cond-tint: #26361A; } }
235
- body[data-layout="beside"] .block { cursor: pointer; border-radius: 6px; }
236
- /* A site's own characters are tinted, not its whole lines: the
237
- expression is what its grid is about. */
238
- /* The padding stretches the tint to the full 32px line, as tall
239
- as a method's band, without moving the text. */
240
- mark.site { color: inherit; border-radius: 3px; padding: 8px 0; }
241
- mark.site { background: var(--cond-tint); }
242
- mark.site[data-status="gaps"] { box-shadow: inset 0 -1px 0 var(--bad); }
243
- mark.site[data-status="covered"] { box-shadow: inset 0 -1px 0 var(--ok); }
244
- /* An open site, like an open method's bar, has its status edges
245
- doubled to 2px: its button's top and left, and its
246
- expressions' underlines. */
247
- body[data-layout="beside"] button.lnum[aria-expanded="true"][data-status="gaps"] { box-shadow: inset 1px 1px 0 var(--bad); }
248
- body[data-layout="beside"] button.lnum[aria-expanded="true"][data-status="covered"] { box-shadow: inset 1px 1px 0 var(--ok); }
249
- body[data-layout="beside"] .block:has(> button.lnum[aria-expanded="true"]) mark.site[data-status="gaps"] { box-shadow: inset 0 -2px 0 var(--bad); }
250
- body[data-layout="beside"] .block:has(> button.lnum[aria-expanded="true"]) mark.site[data-status="covered"] { box-shadow: inset 0 -2px 0 var(--ok); }
251
- /* Beside, a jump to a site opens its tree, whose doubled edges
252
- mark it, so its button has no outline of the jump to it; and
253
- while a method's paths are open, none keeps a focus outline. */
254
- body[data-layout="beside"] button.lnum:has(.lineno:target) { outline: none; }
255
- body[data-open="pc"] button.lnum:focus-visible { outline: none; }
256
- body[data-layout="beside"] .block .srcs { flex: 1; }
257
- body[data-layout="beside"] .block:hover { filter: brightness(0.97); }
258
- /* Beside, an open site's triangle points left, showing that a
259
- click closes its tree, rather than down. */
260
- /* A site's tree opens in the left rail: a closed button points
261
- left, where its tree will open, an open one right, the way it
262
- will close. */
263
- body[data-layout="beside"] button.lnum::before { content: "\25C2"; transform: none; }
264
- body[data-layout="beside"] button.lnum[aria-expanded="true"]::before { content: "\25B8"; transform: none; }
313
+ .divider:hover::after, .divider.dragging::after { background: var(--link); }
314
+ body.dragging { cursor: col-resize; user-select: none; }
265
315
 
266
- /* SPIKE: a path method's bar on the code pane's right edge,
267
- def to end, which opens its grid out into the rail: a column
268
- per path, never-taken first, each row level with its line. */
269
- .pathbar {
270
- position: absolute; width: 16px; padding: 0; z-index: 3;
271
- border: 0; border-radius: 4px; cursor: pointer;
272
- display: flex; align-items: center; justify-content: center;
273
- color: var(--on-status); font-size: 11px;
316
+ /* Within each method, each line of a method has a stripe in the
317
+ method's status colour, just left of its def's d, from its def
318
+ line to its last; its def line also has a band of the one tint,
319
+ from its def to the end of its text. Both are backgrounds of the
320
+ lines' code, placed in characters (side.js gives each line its
321
+ def's column), so the code's own layout keeps them aligned. Open,
322
+ a method's stripe thickens. */
323
+ /* Within each method, a method's body is folded under its def line
324
+ until its def's number opens it, so the page starts as a list of
325
+ def lines. */
326
+ .method-folded { display: none; }
327
+ /* The open method's def line, shifted down by side.js to stay just
328
+ below the sticky header, covers the body lines passing under it. */
329
+ .def-stuck {
330
+ position: relative; z-index: 3; background: var(--surface);
331
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
274
332
  }
275
- .pathbar::after { content: "\25B8"; }
276
- .pathbar[aria-expanded="true"]::after { content: "\25C2"; }
277
- /* A method's def line, lit from its def to its bar, under the
278
- code's text; the code is its own stacking context so the band
279
- can sit beneath its rows. */
280
- body[data-layout="beside"] .code { position: relative; isolation: isolate; }
281
- .methodband { position: absolute; z-index: -1; border-radius: 6px 0 0 6px; pointer-events: none; }
282
- /* A method's band is violet, whatever its status, so it never
283
- reads as a site's band; its status is its bar's colour and its
284
- bottom line's. */
285
- :root { --path-tint: #E9E0FB; }
286
- @media (prefers-color-scheme: dark) { :root { --path-tint: #33284F; } }
287
- .methodband { background: var(--path-tint); }
288
- .methodband[data-status="gaps"] { box-shadow: inset 0 1px 0 var(--bad); }
289
- .methodband[data-status="covered"] { box-shadow: inset 0 1px 0 var(--ok); }
290
- .line:has(.lineno) { cursor: default; }
291
- /* A bar is violet like its method's band, so violet always means
292
- paths; its status is a line down its right edge, as the band's
293
- is a line along its top. */
294
- .pathbar {
295
- background: var(--path-tint); color: var(--fg);
296
- border-radius: 0 0 4px 4px; align-items: flex-start; line-height: 32px;
333
+ .src.in-method {
334
+ --method-colour: var(--bad); --stripe: 2px;
335
+ --at: calc(var(--def-col) * 1ch - 4px);
336
+ background-image: linear-gradient(var(--method-colour), var(--method-colour));
337
+ background-size: var(--stripe) 100%;
338
+ background-position: var(--at) 0;
339
+ background-repeat: no-repeat;
340
+ }
341
+ .src.in-method[data-method-status="covered"] { --method-colour: var(--ok); }
342
+ .src.in-method.method-open { --stripe: 3px; }
343
+ /* A def line's band stops 1px short of its line's bottom, so the
344
+ bands of def lines one after another, eg one-line methods, stay
345
+ apart. Its stripe runs the full height, on into its body, but on
346
+ its method's last line, where it too stops 1px short, so the
347
+ stripes of methods one after another stay apart as well. */
348
+ .src.def-line {
349
+ --band: calc((var(--def-end) - var(--def-col)) * 1ch + 8px) calc(100% - 1px);
350
+ background-image:
351
+ linear-gradient(var(--method-colour), var(--method-colour)),
352
+ linear-gradient(var(--cond-tint), var(--cond-tint));
353
+ background-size: var(--stripe) 100%, var(--band);
354
+ background-position: var(--at) 0, var(--at) 0;
297
355
  }
298
- .pathbar[data-status="gaps"] { box-shadow: inset -1px 0 0 var(--bad), inset 0 1px 0 var(--bad); }
299
- .pathbar[data-status="covered"] { box-shadow: inset -1px 0 0 var(--ok), inset 0 1px 0 var(--ok); }
300
- /* Open, a method's status lines thicken, on its bar and band. */
301
- .pathbar[aria-expanded="true"][data-status="gaps"] { box-shadow: inset -2px 0 0 var(--bad), inset 0 2px 0 var(--bad); }
302
- .pathbar[aria-expanded="true"][data-status="covered"] { box-shadow: inset -2px 0 0 var(--ok), inset 0 2px 0 var(--ok); }
303
- .methodband.open[data-status="gaps"] { box-shadow: inset 0 2px 0 var(--bad); }
304
- .methodband.open[data-status="covered"] { box-shadow: inset 0 2px 0 var(--ok); }
305
- .pathbar:hover { filter: brightness(1.15); }
356
+ .src.in-method.method-end { background-size: var(--stripe) calc(100% - 1px); }
357
+ .src.def-line.method-end { background-size: var(--stripe) calc(100% - 1px), var(--band); }
358
+ /* A card floats in the rail, level with its first line (its top
359
+ set by side.js), framed by a border, rounded corners and a
360
+ shadow, its rows 16px in from its sides. */
306
361
  .rail .pathgrid {
307
362
  position: absolute; left: 0; right: 0; z-index: 2; overflow-x: auto; overflow-y: hidden;
308
- background: var(--path-tint); border-radius: 6px; font: 600 12px var(--font-code);
363
+ background: var(--cond-tint); font: 600 12px var(--font-code);
364
+ border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
309
365
  }
310
- .prow { position: absolute; left: 0; display: flex; gap: 2px; white-space: nowrap; }
311
- .plabel { width: 48px; flex-shrink: 0; text-align: right; padding-right: 8px; color: var(--muted); line-height: 24px; }
366
+ .prow { position: absolute; left: 16px; display: flex; gap: 2px; white-space: nowrap; }
367
+ /* A statement card's rows flow down it, 10px above the first and
368
+ below the last, so a fold open under a row pushes the rows after
369
+ it down. */
370
+ .statements { padding: 10px 0; }
371
+ .statements .prow { position: static; padding: 0 16px; margin-bottom: 2px; }
372
+ /* A site's fold draws the site's tree in the code's font, its
373
+ rows as tall as the card's. Open, it takes its row's
374
+ place right of the row's arrow and line:col, 88px in (the card's
375
+ 16px padding, the arrow's 16px, the label's 52px and two 2px
376
+ gaps): its first row, the site's operator and its count on each
377
+ path, stands where the row's top and counts were, which hide,
378
+ and its other rows are indented as far, so they stay aligned
379
+ with the operator. The rows it reveals, below its first row
380
+ (24px and 2px padding), are tinted a shade off the card,
381
+ toward the text colour, so in either theme they stand out as
382
+ opened, with no rule needed above or below them. Lying over
383
+ its row, it takes no click itself, so one on the row's arrow
384
+ or line:col beneath reaches the row and folds it back; its
385
+ tree's rows take theirs. */
386
+ .fold {
387
+ position: relative; margin: -26px 0 6px; padding: 0 16px 4px 88px;
388
+ font: 400 13px var(--font-code); line-height: 24px; color: var(--fg);
389
+ pointer-events: none;
390
+ background: linear-gradient(transparent 26px,
391
+ color-mix(in srgb, var(--cond-tint), var(--fg) 6%) 26px);
392
+ }
393
+ .fold:last-child { margin-bottom: 0; }
394
+ .fold .site { pointer-events: auto; }
395
+ .fold .bx { height: 24px; }
396
+ .fold .site > .row:first-child {
397
+ border-bottom: 0; margin: 0 0 4px; padding: 0 0 2px; cursor: pointer;
398
+ }
399
+ .statements .prow.site:has(> .fold-arrow[aria-expanded="true"]) > .pcell { visibility: hidden; }
400
+ /* A site row's arrow, left of its line:col, points down while its
401
+ fold is shut and up while it is open; every other row's label
402
+ is indented by the arrow's width and the gap after it, so the
403
+ labels line up. */
404
+ .fold-arrow {
405
+ flex: none; width: 16px; padding: 0; border: none; background: none;
406
+ font: inherit; font-size: 10px; line-height: 24px; color: var(--muted); cursor: pointer;
407
+ }
408
+ .fold-arrow::before { content: "\25BC"; }
409
+ .fold-arrow[aria-expanded="true"]::before { content: "\25B2"; }
410
+ .prow.site:hover .fold-arrow, .fold-arrow[aria-expanded="true"] { color: var(--link); }
411
+ .fold-arrow:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
412
+ .statements .prow > .plabel:first-child { margin-left: 18px; }
413
+ /* A grid's line labels sit at its left padding, as a tree's labels
414
+ do, their fixed width keeping the cells in columns. */
415
+ .plabel { width: 48px; flex-shrink: 0; text-align: left; padding-right: 8px; color: var(--muted); line-height: 24px; }
312
416
  .pcell { width: 24px; flex-shrink: 0; text-align: center; line-height: 24px; border-radius: 3px; }
313
- .pcell.ended { background: transparent; }
314
- .pcell.true, .pcell.false { background: var(--surface); color: var(--fg); }
315
- .prow.calls .pcell.taken { background: var(--ok-tint); color: var(--ok); }
316
- .prow.calls .pcell.never { background: var(--bad); color: var(--on-status); }
417
+ /* A statement card's cells hold words, eg return, not T or F. Its
418
+ line:col labels are narrow, so each row's top follows close
419
+ after, left aligned, its paths and taken at the card's right
420
+ edge; the title row's name is as wide as it needs. */
421
+ .statements .pcell { width: 72px; cursor: default; }
422
+ .statements .plabel { width: 44px; padding-right: 8px; overflow: visible; }
423
+ .statements .prow.calls .plabel { width: auto; }
424
+ .statements .plabel + .pcell { flex: 1; min-width: 56px; text-align: left; }
425
+ .statements .prow.site, .statements .prow.site .pcell { cursor: pointer; }
426
+ .statements .prow.site:hover .pcell, .statements .prow.site:hover .plabel { color: var(--link); }
427
+ .statements .prow.columns .plabel, .statements .prow.columns .pcell { color: var(--muted); }
428
+ /* A card's paths not taken are orange and those taken blue, as a
429
+ status always is; its column titles are too, as their key. None
430
+ not taken, 0, is no gap, so is blue. */
431
+ .statements .pcell.not-taken { color: var(--bad); }
432
+ .statements .pcell.was-taken,
433
+ .statements .pcell.not-taken.none { color: var(--ok); }
317
434
  .prow.calls .plabel { color: var(--fg); }
318
- /* SPIKE: hovering a path's column shows it in the code: the
319
- column outlined, skipped lines faded, each decision's line
320
- chipped with its outcome. */
321
- .pcell { cursor: default; }
322
- .pcell { cursor: pointer; }
323
- .pcell.hot { outline: 2px solid var(--fg); outline-offset: -1px; }
324
- .pcell.pinned { outline: 3px solid var(--link); outline-offset: -2px; }
325
- :root { --lit: #FFE98A; }
326
- @media (prefers-color-scheme: dark) { :root { --lit: #5A4A12; } }
327
- /* A lit line's background spans the code pane's full width. */
328
- .line .src { flex: 1; }
329
- .src.lit { background: var(--path-tint); }
435
+ /* Hovering a card's row lights its line in the code; hovering a
436
+ fold's row marks the characters of its operand. */
437
+ .src.lit { background: var(--cond-tint); }
330
438
  mark.chars { background: var(--lit); color: inherit; border-radius: 3px; box-shadow: 0 0 0 2px var(--lit); }
331
- .tree .row[data-at] { cursor: default; }
332
- .tree .row[data-at]:hover { background: rgba(255, 255, 255, 0.08); }
333
- .nav[data-chip] { flex-direction: row; align-items: center; justify-content: flex-end; padding-right: 2px; box-sizing: border-box; }
334
- .nav[data-chip] a { display: none; }
335
- .nav[data-chip]::after {
336
- content: attr(data-chip); padding: 0 7px; border-radius: 4px;
337
- font: 700 11px/20px var(--font-body); background: var(--fg); color: var(--bg);
439
+ .fold .row[data-at] { cursor: default; }
440
+ .fold .row[data-at]:hover { background: rgba(255, 255, 255, 0.08); }
441
+
442
+ /* A row of jumps with none keeps its height, though hidden, so the
443
+ sticky header, and the code below it, never move. */
444
+ .jump-list[data-empty] { visibility: hidden; }
445
+ /* The number of each method's def line wears a loose site's
446
+ button's look: the one tint, edged on the top and left in its
447
+ status colour, orange for gaps and blue for covered, with an
448
+ arrow pointing left while its card is closed, and none while it
449
+ is open. Its 63px and its 9px right margin take the 72px a plain
450
+ number takes, as a loose site's button does, so its line's code
451
+ starts where every other line's does and its digits end where
452
+ theirs do. */
453
+ .lineno.mdef {
454
+ position: relative; box-sizing: border-box; width: 63px; padding-right: 11px;
455
+ margin: 4px 9px 4px 0; line-height: 24px; cursor: pointer;
456
+ font: 600 13px/24px var(--font-code); border: 1px solid transparent;
457
+ border-radius: 6px; background: var(--cond-tint);
458
+ --mdef-status: var(--bad); color: var(--mdef-status);
459
+ border-top-color: var(--mdef-status); border-left-color: var(--mdef-status);
460
+ }
461
+ .lineno.mdef[data-status="covered"] { --mdef-status: var(--ok); }
462
+ .lineno.mdef::before {
463
+ content: "\25C2"; position: absolute; left: 7px; top: 0; font-size: 11px;
338
464
  }
465
+ .lineno.mdef[aria-expanded="true"]::before { content: none; }
466
+ .lineno.mdef[aria-expanded="true"] { box-shadow: inset 1px 1px 0 var(--mdef-status); }
467
+ .lineno.mdef:hover { filter: brightness(1.1); }
468
+ /* A line's gap arrows sit in the middle of its row, level with its
469
+ number, however tall its row is. */
470
+ .nav { align-self: stretch; }