path_coverage 0.4.0 → 0.5.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.
- checksums.yaml +4 -4
- data/README.md +286 -199
- data/exe/path_coverage_report +4 -0
- data/lib/path_coverage/call_trace.rb +88 -0
- data/lib/path_coverage/calls.rb +49 -43
- data/lib/path_coverage/card_context.rb +104 -0
- data/lib/path_coverage/card_forks.rb +44 -0
- data/lib/path_coverage/card_gaps.rb +125 -0
- data/lib/path_coverage/card_scopes.rb +37 -0
- data/lib/path_coverage/card_tree.rb +79 -66
- data/lib/path_coverage/card_way_lists.rb +72 -0
- data/lib/path_coverage/card_ways.rb +123 -67
- data/lib/path_coverage/{html_syntax.rb → code_tokens.rb} +35 -33
- data/lib/path_coverage/condition.rb +14 -14
- data/lib/path_coverage/configuration.rb +7 -4
- data/lib/path_coverage/configuration_limits.rb +52 -0
- data/lib/path_coverage/configuration_paths.rb +7 -7
- data/lib/path_coverage/console_summary.rb +24 -22
- data/lib/path_coverage/{site.rb → decision.rb} +2 -2
- data/lib/path_coverage/decision_locations.rb +76 -0
- data/lib/path_coverage/{site_paths.rb → decision_paths.rb} +13 -11
- data/lib/path_coverage/{site_tree.rb → decision_tree.rb} +25 -16
- data/lib/path_coverage/fold_branches.rb +18 -0
- data/lib/path_coverage/fold_cells.rb +42 -0
- data/lib/path_coverage/{html_tree.rb → fold_rows.rb} +42 -71
- data/lib/path_coverage/gaps.rb +33 -15
- data/lib/path_coverage/json_reader.rb +54 -19
- data/lib/path_coverage/json_reports.rb +102 -0
- data/lib/path_coverage/json_writer.rb +27 -12
- data/lib/path_coverage/kernel.rb +56 -58
- data/lib/path_coverage/kinds/base.rb +16 -16
- data/lib/path_coverage/kinds/block.rb +16 -15
- data/lib/path_coverage/kinds/case.rb +14 -12
- data/lib/path_coverage/kinds/chain.rb +40 -11
- data/lib/path_coverage/kinds/choice.rb +4 -3
- data/lib/path_coverage/kinds/contains.rb +40 -32
- data/lib/path_coverage/kinds/safe.rb +38 -26
- data/lib/path_coverage/kinds/write.rb +6 -6
- data/lib/path_coverage/kinds.rb +2 -2
- data/lib/path_coverage/leaving.rb +44 -0
- data/lib/path_coverage/loop_forks.rb +57 -0
- data/lib/path_coverage/loop_nodes.rb +55 -0
- data/lib/path_coverage/manifest.rb +92 -58
- data/lib/path_coverage/manifest_blocks.rb +5 -26
- data/lib/path_coverage/manifest_case.rb +2 -2
- data/lib/path_coverage/manifest_chains.rb +8 -8
- data/lib/path_coverage/manifest_choices.rb +23 -20
- data/lib/path_coverage/manifest_disabled.rb +97 -0
- data/lib/path_coverage/manifest_folding.rb +43 -40
- data/lib/path_coverage/manifest_ignoring.rb +6 -6
- data/lib/path_coverage/manifest_writes.rb +11 -10
- data/lib/path_coverage/measured_by.rb +20 -0
- data/lib/path_coverage/merge.rb +7 -7
- data/lib/path_coverage/method_loops.rb +128 -0
- data/lib/path_coverage/method_statements.rb +130 -127
- data/lib/path_coverage/method_ways.rb +142 -0
- data/lib/path_coverage/paths_report.rb +16 -16
- data/lib/path_coverage/recorder.rb +57 -36
- data/lib/path_coverage/recorder_blocks.rb +17 -17
- data/lib/path_coverage/recorder_cases.rb +12 -11
- data/lib/path_coverage/recorder_chains.rb +12 -12
- data/lib/path_coverage/recorder_writes.rb +9 -9
- data/lib/path_coverage/render.rb +58 -51
- data/lib/path_coverage/result.rb +32 -31
- data/lib/path_coverage/rewriter.rb +39 -27
- data/lib/path_coverage/rewriter_nested.rb +13 -13
- data/lib/path_coverage/runs_report.rb +84 -0
- data/lib/path_coverage/source_lines.rb +16 -16
- data/lib/path_coverage/source_report.rb +100 -0
- data/lib/path_coverage/stable_leaves.rb +162 -0
- data/lib/path_coverage/statement_arms.rb +31 -30
- data/lib/path_coverage/summary.rb +4 -62
- data/lib/path_coverage/totals.rb +10 -8
- data/lib/path_coverage/version.rb +1 -1
- data/lib/path_coverage/walk.rb +106 -0
- data/lib/path_coverage/way_algebras.rb +127 -0
- data/lib/path_coverage/ways_report.rb +91 -0
- data/lib/path_coverage/ways_totals.rb +46 -0
- data/lib/path_coverage/within_methods.rb +135 -80
- metadata +33 -28
- data/lib/path_coverage/card.rb +0 -14
- data/lib/path_coverage/html/file.html +0 -33
- data/lib/path_coverage/html/index.html +0 -29
- data/lib/path_coverage/html/settings.js +0 -50
- data/lib/path_coverage/html/side.js +0 -599
- data/lib/path_coverage/html/sort.js +0 -34
- data/lib/path_coverage/html/style.css +0 -484
- data/lib/path_coverage/html/tabs.js +0 -15
- data/lib/path_coverage/html/theme.js +0 -27
- data/lib/path_coverage/html_branch.rb +0 -30
- data/lib/path_coverage/html_cards.rb +0 -88
- data/lib/path_coverage/html_cells.rb +0 -71
- data/lib/path_coverage/html_file.rb +0 -123
- data/lib/path_coverage/html_index.rb +0 -128
- data/lib/path_coverage/html_index_head.rb +0 -29
- data/lib/path_coverage/html_labels.rb +0 -16
- data/lib/path_coverage/html_methods.rb +0 -66
- data/lib/path_coverage/html_nav.rb +0 -67
- data/lib/path_coverage/html_report.rb +0 -131
- data/lib/path_coverage/html_statements.rb +0 -186
- data/lib/path_coverage/html_tabs.rb +0 -26
- data/lib/path_coverage/html_template.rb +0 -26
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
/* Blue (seen both ways) and orange (missing) stay distinct for
|
|
2
|
-
red-green colour blindness; states also differ in form. */
|
|
3
|
-
:root {
|
|
4
|
-
--bg: #FBFBFC;
|
|
5
|
-
--surface: #FFFFFF;
|
|
6
|
-
--panel: #F2F4F7;
|
|
7
|
-
--fg: #1C2230;
|
|
8
|
-
--muted: #5B6577;
|
|
9
|
-
--rule: #D5DAE2;
|
|
10
|
-
--ok: #1F5FBF;
|
|
11
|
-
--ok-tint: #E6EEFA;
|
|
12
|
-
--bad: #B54708;
|
|
13
|
-
--on-status: #FFFFFF;
|
|
14
|
-
--link: #1F5FBF;
|
|
15
|
-
--font-body: "Helvetica Neue", Arial, sans-serif;
|
|
16
|
-
--font-code: Menlo, Consolas, "DejaVu Sans Mono", monospace;
|
|
17
|
-
}
|
|
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;
|
|
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; }
|
|
54
|
-
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 14px; }
|
|
55
|
-
a { color: var(--link); }
|
|
56
|
-
.page {
|
|
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));
|
|
59
|
-
}
|
|
60
|
-
/* A file's page is wider, to hold its rail beside its code. */
|
|
61
|
-
.page:has(.code) { max-width: 1800px; }
|
|
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; }
|
|
74
|
-
.box { border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); overflow-x: auto; }
|
|
75
|
-
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
|
|
76
|
-
th, td { padding: 10px 16px; text-align: left; }
|
|
77
|
-
th { background: var(--panel); }
|
|
78
|
-
td { border-top: 1px solid var(--rule); }
|
|
79
|
-
td:first-child { font-family: var(--font-code); }
|
|
80
|
-
/* The Total row frames the table's foot as the headings do its
|
|
81
|
-
head, so it reads as a sum, not as one more file. */
|
|
82
|
-
tfoot td { background: var(--panel); font-weight: 600; border-top: 1px solid var(--fg); }
|
|
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; }
|
|
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; }
|
|
100
|
-
th button {
|
|
101
|
-
font: 600 13px var(--font-body); color: var(--fg); background: none; border: 0;
|
|
102
|
-
padding: 4px 0; cursor: pointer;
|
|
103
|
-
}
|
|
104
|
-
th button::after { content: " \2195"; color: var(--muted); }
|
|
105
|
-
th[aria-sort="ascending"] button::after { content: " \25B2"; color: var(--fg); }
|
|
106
|
-
th[aria-sort="descending"] button::after { content: " \25BC"; color: var(--fg); }
|
|
107
|
-
th button:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
|
|
108
|
-
|
|
109
|
-
/* A file's page: plain source; on lines holding a condition the
|
|
110
|
-
line numbers are one button. Every number has the same box, so
|
|
111
|
-
digits stay aligned whether or not they are on a button. */
|
|
112
|
-
h1.path { font-family: var(--font-code); font-size: 18px; }
|
|
113
|
-
/* The top line, and on a file's page its path and site lists,
|
|
114
|
-
stick together as one header. */
|
|
115
|
-
.head {
|
|
116
|
-
position: sticky; top: 0; z-index: 5;
|
|
117
|
-
display: flex; flex-direction: column; gap: 10px;
|
|
118
|
-
margin: 0 -16px; padding: 12px 16px; background: var(--bg);
|
|
119
|
-
border-bottom: 1px solid var(--rule);
|
|
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; }
|
|
130
|
-
.jumps { display: flex; flex-direction: column; gap: 8px; }
|
|
131
|
-
.jump-list { display: flex; gap: 6px; align-items: center; overflow-x: auto; white-space: nowrap; min-width: 0; }
|
|
132
|
-
.jump-label { width: 64px; flex-shrink: 0; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
|
|
133
|
-
a.jump {
|
|
134
|
-
font: 600 12px/22px var(--font-code); padding: 0 9px; border-radius: 999px;
|
|
135
|
-
text-decoration: none; border: 1px solid; font-variant-numeric: tabular-nums;
|
|
136
|
-
}
|
|
137
|
-
/* A site's jump wears the condition tint, edged in its status
|
|
138
|
-
colour on the top and left only, as its line's button is. */
|
|
139
|
-
a.jump[data-status] { background: var(--cond-tint); border-right-color: transparent; border-bottom-color: transparent; }
|
|
140
|
-
a.jump[data-status="covered"] { color: var(--ok); border-top-color: var(--ok); border-left-color: var(--ok); }
|
|
141
|
-
a.jump[data-status="gaps"] { color: var(--bad); border-top-color: var(--bad); border-left-color: var(--bad); }
|
|
142
|
-
a.jump:focus-visible, .nav a:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
|
|
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. */
|
|
155
|
-
.box:has(> .code)::before {
|
|
156
|
-
content: ""; position: absolute; inset: 0 0 0 calc(var(--rail) + 38px); z-index: -1;
|
|
157
|
-
border: 1px solid var(--rule); border-radius: 8px;
|
|
158
|
-
background: var(--surface); pointer-events: none;
|
|
159
|
-
}
|
|
160
|
-
/* The previous-gap arrow sits above the next, each half a line
|
|
161
|
-
tall, keeping the gutter narrow. */
|
|
162
|
-
.nav { display: flex; flex-direction: column; justify-content: center; width: 26px; flex-shrink: 0; }
|
|
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); }
|
|
167
|
-
.nav a:hover { color: var(--fg); }
|
|
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
|
-
}
|
|
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; }
|
|
184
|
-
.srcs { display: flex; flex-direction: column; }
|
|
185
|
-
.block .srcs { flex: 1; }
|
|
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. */
|
|
195
|
-
.lineno {
|
|
196
|
-
display: block; width: 52px; padding-right: 20px; text-align: right;
|
|
197
|
-
color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0;
|
|
198
|
-
scroll-margin-top: 190px;
|
|
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. */
|
|
205
|
-
button.lnum {
|
|
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;
|
|
209
|
-
border: 1px solid transparent; border-radius: 6px; cursor: pointer;
|
|
210
|
-
font: 600 13px/24px var(--font-code); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
|
|
211
|
-
}
|
|
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. */
|
|
215
|
-
button.lnum::before {
|
|
216
|
-
content: "\25C2"; position: absolute; left: 7px; top: 4px;
|
|
217
|
-
font-size: 11px; line-height: 24px;
|
|
218
|
-
}
|
|
219
|
-
button.lnum[aria-expanded="true"]::before { content: none; }
|
|
220
|
-
/* With a site count the count and the triangle share the
|
|
221
|
-
button's height, one 11px line each. */
|
|
222
|
-
button.lnum:has(.site-count)::before { top: 12px; line-height: 11px; }
|
|
223
|
-
/* On a button over two or more lines the triangle sits at the
|
|
224
|
-
very bottom. */
|
|
225
|
-
button.lnum:has(.lineno + .lineno)::before { top: auto; bottom: 2px; line-height: 11px; }
|
|
226
|
-
.site-count {
|
|
227
|
-
position: absolute; left: 7px; top: 1px;
|
|
228
|
-
font-size: 9px; line-height: 11px; font-weight: 700;
|
|
229
|
-
}
|
|
230
|
-
button.lnum .lineno { width: 50px; padding-right: 11px; color: inherit; line-height: 32px; margin: -4px 0; }
|
|
231
|
-
/* A site's button wears the condition tint, edged in its
|
|
232
|
-
status colour on the top and left only. */
|
|
233
|
-
button.lnum[data-status] { box-shadow: none; background: var(--cond-tint); border-right-color: transparent; border-bottom-color: transparent; }
|
|
234
|
-
button.lnum[data-status="covered"] { color: var(--ok); border-top-color: var(--ok); border-left-color: var(--ok); }
|
|
235
|
-
button.lnum[data-status="gaps"] { color: var(--bad); border-top-color: var(--bad); border-left-color: var(--bad); }
|
|
236
|
-
button.lnum:hover { filter: brightness(1.1); }
|
|
237
|
-
button.lnum:focus-visible { outline: 3px solid var(--link); outline-offset: 1px; }
|
|
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;
|
|
259
|
-
}
|
|
260
|
-
.operator { font-weight: 600; }
|
|
261
|
-
.row .arm { white-space: pre; font-weight: 600; }
|
|
262
|
-
.branch { white-space: pre; color: var(--muted); margin-right: -16px; }
|
|
263
|
-
/* A leaf's text is never wider than 48ch, nor than its row has
|
|
264
|
-
room for: the rest of a long one scrolls within it, so its
|
|
265
|
-
cells stay in their columns at the row's right edge. */
|
|
266
|
-
.row .text {
|
|
267
|
-
white-space: pre; min-width: 0; max-width: 48ch;
|
|
268
|
-
overflow-x: auto; scrollbar-width: thin;
|
|
269
|
-
}
|
|
270
|
-
/* A branch's cell, of the kind its data-bx names, drawn a whole
|
|
271
|
-
row tall so branches join from row to row: v a vertical line,
|
|
272
|
-
t a vertical with a stub right, l the top half of a vertical
|
|
273
|
-
with a stub right, h a horizontal, s nothing. */
|
|
274
|
-
.bx { display: inline-block; width: 1ch; height: 30px; vertical-align: top; --stroke: linear-gradient(currentColor, currentColor); }
|
|
275
|
-
.bx[data-bx="v"] { background: var(--stroke) 50% 0 / 1px 100% no-repeat; }
|
|
276
|
-
.bx[data-bx="t"] { background: var(--stroke) 50% 0 / 1px 100% no-repeat, var(--stroke) 100% 50% / 50% 1px no-repeat; }
|
|
277
|
-
.bx[data-bx="l"] { background: var(--stroke) 50% 0 / 1px 50% no-repeat, var(--stroke) 100% 50% / 50% 1px no-repeat; }
|
|
278
|
-
.bx[data-bx="h"] { background: var(--stroke) 0 50% / 100% 1px no-repeat; }
|
|
279
|
-
/* Each path heads its column with a snake, a vertical ~ standing
|
|
280
|
-
for the path below it, then 0, orange, for a path never taken,
|
|
281
|
-
or *, blue, for one taken, its count on hover; a leaf's T or F
|
|
282
|
-
on that path sits in a chip, as in a path grid, and a blank
|
|
283
|
-
means the path never reached it. */
|
|
284
|
-
.row .count { text-align: center; font-variant-numeric: tabular-nums; color: var(--ok); font-weight: 600; }
|
|
285
|
-
.row .count::before { content: "\2240"; }
|
|
286
|
-
.row .count.never { color: var(--bad); }
|
|
287
|
-
.row .cell { text-align: center; }
|
|
288
|
-
.row .cell:is(:not(:empty), [data-mark]) {
|
|
289
|
-
align-self: center; line-height: 22px; border-radius: 3px;
|
|
290
|
-
background: var(--surface); color: var(--fg); font: 600 12px var(--font-code);
|
|
291
|
-
}
|
|
292
|
-
/* A cell's mark, drawn in place of a letter: a tick for a path
|
|
293
|
-
that took a ?:'s arm, a return arrow for one that left the
|
|
294
|
-
method at a return or a raise, a disc for a &. receiver not
|
|
295
|
-
nil, an empty set for one nil. */
|
|
296
|
-
.row .cell[data-mark="taken"]::before { content: "\2713"; }
|
|
297
|
-
.row .cell[data-mark="leaves"]::before { content: "\21A9"; }
|
|
298
|
-
.row .cell[data-mark="present"]::before { content: "\25CF"; }
|
|
299
|
-
.row .cell[data-mark="absent"]::before { content: "\2205"; }
|
|
300
|
-
/* Hovering a cell with hover text, eg a path's count or a &.
|
|
301
|
-
receiver's mark, shows that text in a chip above it. */
|
|
302
|
-
.row [data-hover] { position: relative; cursor: default; }
|
|
303
|
-
.row [data-hover]:hover::after {
|
|
304
|
-
content: attr(data-hover); position: absolute; bottom: 100%; left: 50%;
|
|
305
|
-
transform: translateX(-50%); z-index: 4; padding: 0 7px; border-radius: 4px;
|
|
306
|
-
white-space: nowrap; font: 700 11px/20px var(--font-body); background: var(--fg); color: var(--bg);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/* The divider: the gap between the rail and the code, a line down
|
|
310
|
-
its middle that darkens as it is hovered or dragged. */
|
|
311
|
-
.divider {
|
|
312
|
-
position: absolute; top: 0; bottom: 0; left: var(--rail); width: 12px;
|
|
313
|
-
cursor: col-resize; z-index: 4; touch-action: none;
|
|
314
|
-
}
|
|
315
|
-
.divider::after {
|
|
316
|
-
content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px;
|
|
317
|
-
background: var(--rule);
|
|
318
|
-
}
|
|
319
|
-
.divider:hover::after, .divider.dragging::after { background: var(--link); }
|
|
320
|
-
body.dragging { cursor: col-resize; user-select: none; }
|
|
321
|
-
|
|
322
|
-
/* Within each method, each line of a method has a stripe in the
|
|
323
|
-
method's status colour, just left of its def's d, from its def
|
|
324
|
-
line to its last; its def line also has a band of the one tint,
|
|
325
|
-
from its def to the end of its text. Both are backgrounds of the
|
|
326
|
-
lines' code, placed in characters (side.js gives each line its
|
|
327
|
-
def's column), so the code's own layout keeps them aligned. Open,
|
|
328
|
-
a method's stripe thickens. */
|
|
329
|
-
/* Within each method, a method's body is folded under its def line
|
|
330
|
-
until its def's number opens it, so the page starts as a list of
|
|
331
|
-
def lines. */
|
|
332
|
-
.method-folded { display: none; }
|
|
333
|
-
/* The open method's def line, shifted down by side.js to stay just
|
|
334
|
-
below the sticky header, covers the body lines passing under it. */
|
|
335
|
-
.def-stuck {
|
|
336
|
-
position: relative; z-index: 3; background: var(--surface);
|
|
337
|
-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
338
|
-
}
|
|
339
|
-
.src.in-method {
|
|
340
|
-
--method-colour: var(--bad); --stripe: 2px;
|
|
341
|
-
--at: calc(var(--def-col) * 1ch - 4px);
|
|
342
|
-
background-image: linear-gradient(var(--method-colour), var(--method-colour));
|
|
343
|
-
background-size: var(--stripe) 100%;
|
|
344
|
-
background-position: var(--at) 0;
|
|
345
|
-
background-repeat: no-repeat;
|
|
346
|
-
}
|
|
347
|
-
.src.in-method[data-method-status="covered"] { --method-colour: var(--ok); }
|
|
348
|
-
.src.in-method.method-open { --stripe: 3px; }
|
|
349
|
-
/* A def line's band stops 1px short of its line's bottom, so the
|
|
350
|
-
bands of def lines one after another, eg one-line methods, stay
|
|
351
|
-
apart. Its stripe runs the full height, on into its body, but on
|
|
352
|
-
its method's last line, where it too stops 1px short, so the
|
|
353
|
-
stripes of methods one after another stay apart as well. */
|
|
354
|
-
.src.def-line {
|
|
355
|
-
--band: calc((var(--def-end) - var(--def-col)) * 1ch + 8px) calc(100% - 1px);
|
|
356
|
-
background-image:
|
|
357
|
-
linear-gradient(var(--method-colour), var(--method-colour)),
|
|
358
|
-
linear-gradient(var(--cond-tint), var(--cond-tint));
|
|
359
|
-
background-size: var(--stripe) 100%, var(--band);
|
|
360
|
-
background-position: var(--at) 0, var(--at) 0;
|
|
361
|
-
}
|
|
362
|
-
.src.in-method.method-end { background-size: var(--stripe) calc(100% - 1px); }
|
|
363
|
-
.src.def-line.method-end { background-size: var(--stripe) calc(100% - 1px), var(--band); }
|
|
364
|
-
/* A card floats in the rail, level with its first line (its top
|
|
365
|
-
set by side.js), framed by a border, rounded corners and a
|
|
366
|
-
shadow, its rows 16px in from its sides. */
|
|
367
|
-
.rail .pathgrid {
|
|
368
|
-
position: absolute; left: 0; right: 0; z-index: 2; overflow-x: auto; overflow-y: hidden;
|
|
369
|
-
background: var(--cond-tint); font: 600 12px var(--font-code);
|
|
370
|
-
border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
|
|
371
|
-
}
|
|
372
|
-
.prow { position: absolute; left: 16px; display: flex; gap: 2px; white-space: nowrap; }
|
|
373
|
-
/* A statement card's rows flow down it, 10px above the first and
|
|
374
|
-
below the last, so a fold open under a row pushes the rows after
|
|
375
|
-
it down. */
|
|
376
|
-
.statements { padding: 10px 0; }
|
|
377
|
-
.statements .prow { position: static; padding: 0 16px; margin-bottom: 2px; }
|
|
378
|
-
/* A site's fold draws the site's tree in the code's font, its
|
|
379
|
-
rows as tall as the card's. Open, it takes its row's
|
|
380
|
-
place right of the row's arrow and line:col, 88px in (the card's
|
|
381
|
-
16px padding, the arrow's 16px, the label's 52px and two 2px
|
|
382
|
-
gaps): its first row, the site's operator and its count on each
|
|
383
|
-
path, stands where the row's top and counts were, which hide,
|
|
384
|
-
and its other rows are indented as far, so they stay aligned
|
|
385
|
-
with the operator. The rows it reveals, below its first row
|
|
386
|
-
(24px and 2px padding), are tinted a shade off the card,
|
|
387
|
-
toward the text colour, so in either theme they stand out as
|
|
388
|
-
opened, with no rule needed above or below them. Lying over
|
|
389
|
-
its row, it takes no click itself, so one on the row's arrow
|
|
390
|
-
or line:col beneath reaches the row and folds it back; its
|
|
391
|
-
tree's rows take theirs. */
|
|
392
|
-
.fold {
|
|
393
|
-
position: relative; margin: -26px 0 6px; padding: 0 16px 4px 88px;
|
|
394
|
-
font: 400 13px var(--font-code); line-height: 24px; color: var(--fg);
|
|
395
|
-
pointer-events: none;
|
|
396
|
-
background: linear-gradient(transparent 26px,
|
|
397
|
-
color-mix(in srgb, var(--cond-tint), var(--fg) 6%) 26px);
|
|
398
|
-
}
|
|
399
|
-
.fold:last-child { margin-bottom: 0; }
|
|
400
|
-
.fold .site { pointer-events: auto; }
|
|
401
|
-
.fold .bx { height: 24px; }
|
|
402
|
-
.fold .site > .row:first-child {
|
|
403
|
-
border-bottom: 0; margin: 0 0 4px; padding: 0 0 2px; cursor: pointer;
|
|
404
|
-
}
|
|
405
|
-
.statements .prow.site:has(> .fold-arrow[aria-expanded="true"]) > .pcell { visibility: hidden; }
|
|
406
|
-
/* A site row's arrow, left of its line:col, points down while its
|
|
407
|
-
fold is shut and up while it is open; every other row's label
|
|
408
|
-
is indented by the arrow's width and the gap after it, so the
|
|
409
|
-
labels line up. */
|
|
410
|
-
.fold-arrow {
|
|
411
|
-
flex: none; width: 16px; padding: 0; border: none; background: none;
|
|
412
|
-
font: inherit; font-size: 10px; line-height: 24px; color: var(--muted); cursor: pointer;
|
|
413
|
-
}
|
|
414
|
-
.fold-arrow::before { content: "\25BC"; }
|
|
415
|
-
.fold-arrow[aria-expanded="true"]::before { content: "\25B2"; }
|
|
416
|
-
.prow.site:hover .fold-arrow, .fold-arrow[aria-expanded="true"] { color: var(--link); }
|
|
417
|
-
.fold-arrow:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
|
|
418
|
-
.statements .prow > .plabel:first-child { margin-left: 18px; }
|
|
419
|
-
/* A grid's line labels sit at its left padding, as a tree's labels
|
|
420
|
-
do, their fixed width keeping the cells in columns. */
|
|
421
|
-
.plabel { width: 48px; flex-shrink: 0; text-align: left; padding-right: 8px; color: var(--muted); line-height: 24px; }
|
|
422
|
-
.pcell { width: 24px; flex-shrink: 0; text-align: center; line-height: 24px; border-radius: 3px; }
|
|
423
|
-
/* A statement card's cells hold words, eg return, not T or F. Its
|
|
424
|
-
line:col labels are narrow, so each row's top follows close
|
|
425
|
-
after, left aligned, its paths and taken at the card's right
|
|
426
|
-
edge; the title row's name is as wide as it needs. */
|
|
427
|
-
.statements .pcell { width: 72px; cursor: default; }
|
|
428
|
-
.statements .plabel { width: 44px; padding-right: 8px; overflow: visible; }
|
|
429
|
-
.statements .prow.calls .plabel { width: auto; }
|
|
430
|
-
.statements .plabel + .pcell { flex: 1; min-width: 56px; text-align: left; }
|
|
431
|
-
.statements .prow.site, .statements .prow.site .pcell { cursor: pointer; }
|
|
432
|
-
.statements .prow.site:hover .pcell:not(.not-taken):not(.was-taken), .statements .prow.site:hover .plabel { color: var(--link); }
|
|
433
|
-
.statements .prow.columns .plabel, .statements .prow.columns .pcell { color: var(--muted); }
|
|
434
|
-
/* A card's paths not taken are orange and those taken blue, as a
|
|
435
|
-
status always is; its column titles are too, as their key. None
|
|
436
|
-
not taken, 0, is no gap, so is blue. */
|
|
437
|
-
.statements .pcell.not-taken { color: var(--bad); }
|
|
438
|
-
.statements .pcell.was-taken,
|
|
439
|
-
.statements .pcell.not-taken.none { color: var(--ok); }
|
|
440
|
-
.prow.calls .plabel { color: var(--fg); }
|
|
441
|
-
/* How many times a card's method was called, after its name; a gap,
|
|
442
|
-
never called, coloured as one. */
|
|
443
|
-
.call-count { margin-left: 6px; color: var(--muted); font-weight: 400; }
|
|
444
|
-
.call-count.never { color: var(--bad); font-weight: 600; }
|
|
445
|
-
/* Hovering a card's row lights its line in the code; hovering a
|
|
446
|
-
fold's row marks the characters of its operand. */
|
|
447
|
-
.src.lit { background: var(--cond-tint); }
|
|
448
|
-
mark.chars { background: var(--lit); color: inherit; border-radius: 3px; box-shadow: 0 0 0 2px var(--lit); }
|
|
449
|
-
/* The fold row of the code under the pointer, lit as marked code is. */
|
|
450
|
-
.fold .row.hovered, .statements .prow.hovered {
|
|
451
|
-
background: var(--lit); border-radius: 3px;
|
|
452
|
-
}
|
|
453
|
-
.fold .row[data-at] { cursor: default; }
|
|
454
|
-
.fold .row[data-at]:hover { background: rgba(255, 255, 255, 0.08); }
|
|
455
|
-
|
|
456
|
-
/* A row of jumps with none keeps its height, though hidden, so the
|
|
457
|
-
sticky header, and the code below it, never move. */
|
|
458
|
-
.jump-list[data-empty] { visibility: hidden; }
|
|
459
|
-
/* The number of each method's def line wears a loose site's
|
|
460
|
-
button's look: the one tint, edged on the top and left in its
|
|
461
|
-
status colour, orange for gaps and blue for covered, with an
|
|
462
|
-
arrow pointing left while its card is closed, and none while it
|
|
463
|
-
is open. Its 63px and its 9px right margin take the 72px a plain
|
|
464
|
-
number takes, as a loose site's button does, so its line's code
|
|
465
|
-
starts where every other line's does and its digits end where
|
|
466
|
-
theirs do. */
|
|
467
|
-
.lineno.mdef {
|
|
468
|
-
position: relative; box-sizing: border-box; width: 63px; padding-right: 11px;
|
|
469
|
-
margin: 4px 9px 4px 0; line-height: 24px; cursor: pointer;
|
|
470
|
-
font: 600 13px/24px var(--font-code); border: 1px solid transparent;
|
|
471
|
-
border-radius: 6px; background: var(--cond-tint);
|
|
472
|
-
--mdef-status: var(--bad); color: var(--mdef-status);
|
|
473
|
-
border-top-color: var(--mdef-status); border-left-color: var(--mdef-status);
|
|
474
|
-
}
|
|
475
|
-
.lineno.mdef[data-status="covered"] { --mdef-status: var(--ok); }
|
|
476
|
-
.lineno.mdef::before {
|
|
477
|
-
content: "\25C2"; position: absolute; left: 7px; top: 0; font-size: 11px;
|
|
478
|
-
}
|
|
479
|
-
.lineno.mdef[aria-expanded="true"]::before { content: none; }
|
|
480
|
-
.lineno.mdef[aria-expanded="true"] { box-shadow: inset 1px 1px 0 var(--mdef-status); }
|
|
481
|
-
.lineno.mdef:hover { filter: brightness(1.1); }
|
|
482
|
-
/* A line's gap arrows sit in the middle of its row, level with its
|
|
483
|
-
number, however tall its row is. */
|
|
484
|
-
.nav { align-self: stretch; }
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Switches the index page's tabs: a click on a tab selects it and
|
|
2
|
-
// shows the table it controls, hiding every other tab's table.
|
|
3
|
-
(function () {
|
|
4
|
-
var tabs = Array.from(document.querySelectorAll('[role="tab"]'));
|
|
5
|
-
tabs.forEach(function (tab) {
|
|
6
|
-
tab.addEventListener('click', function () {
|
|
7
|
-
tabs.forEach(function (other) {
|
|
8
|
-
var selected = other === tab;
|
|
9
|
-
other.setAttribute('aria-selected', selected ? 'true' : 'false');
|
|
10
|
-
var table = document.getElementById(other.getAttribute('aria-controls'));
|
|
11
|
-
table.hidden = !selected;
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
})();
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Switches the page between light and dark as the title bar's theme
|
|
2
|
-
// button is pressed: the page's html element names the theme, and
|
|
3
|
-
// the page's CSS draws it. The theme is a setting, carried from page
|
|
4
|
-
// to page as settings.js has it; a page with none opens dark.
|
|
5
|
-
(function () {
|
|
6
|
-
var settings = window.pathCoverageSettings;
|
|
7
|
-
var button = document.querySelector('button.theme');
|
|
8
|
-
if (!button) { return; }
|
|
9
|
-
|
|
10
|
-
// Names theme on the html element, labels the button with the
|
|
11
|
-
// theme it switches to, and makes every link carry theme.
|
|
12
|
-
function show(theme) {
|
|
13
|
-
document.documentElement.setAttribute('data-theme', theme);
|
|
14
|
-
var other = theme === 'dark' ? 'light' : 'dark';
|
|
15
|
-
button.textContent = theme === 'dark' ? '☀' : '☾';
|
|
16
|
-
button.setAttribute('aria-label', 'Switch to ' + other);
|
|
17
|
-
button.title = 'Switch to ' + other;
|
|
18
|
-
settings.carry('theme', theme);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
show(settings.given('theme', ['light', 'dark']) || 'dark');
|
|
22
|
-
button.addEventListener('click', function () {
|
|
23
|
-
var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
|
|
24
|
-
show(theme);
|
|
25
|
-
settings.keep('theme', theme);
|
|
26
|
-
});
|
|
27
|
-
})();
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module PathCoverage
|
|
2
|
-
# The branches of a site's tree on a file's page, joining each
|
|
3
|
-
# operand's row to its operator's. A branch is a string of
|
|
4
|
-
# kinds, one letter per cell: t a tee, l an ell, v a bar, h a
|
|
5
|
-
# dash, s a space. CSS draws each kind as lines a whole row
|
|
6
|
-
# tall, so a branch joins the rows above and below it.
|
|
7
|
-
module HtmlBranch
|
|
8
|
-
# The branch to an operand with more after it.
|
|
9
|
-
TEE = 'ths'.freeze
|
|
10
|
-
# The branch to the last operand.
|
|
11
|
-
ELL = 'lhs'.freeze
|
|
12
|
-
# The indent under an operand with more after it, its bar
|
|
13
|
-
# running on down to them.
|
|
14
|
-
BAR = 'vss'.freeze
|
|
15
|
-
# The indent under the last operand.
|
|
16
|
-
GAP = 'sss'.freeze
|
|
17
|
-
|
|
18
|
-
# Example: ths gives a tee, a dash and a space cell.
|
|
19
|
-
# The cell drawing branch: a cell of each of its kinds,
|
|
20
|
-
# hidden from screen readers, as the rows' order already
|
|
21
|
-
# says how they nest.
|
|
22
|
-
def self.cell(branch)
|
|
23
|
-
cells = branch.chars.map do |kind|
|
|
24
|
-
%(<span class="bx" data-bx="#{kind}"></span>)
|
|
25
|
-
end
|
|
26
|
-
attrs = 'class="branch" data-branch="" aria-hidden="true"'
|
|
27
|
-
%(<span #{attrs}>#{cells.join}</span>)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
require_relative 'card'
|
|
2
|
-
require_relative 'html_statements'
|
|
3
|
-
require_relative 'html_tree'
|
|
4
|
-
require_relative 'site_tree'
|
|
5
|
-
require_relative 'within_methods'
|
|
6
|
-
|
|
7
|
-
module PathCoverage
|
|
8
|
-
# The cards of one file's page, as Card gives them, in the rail
|
|
9
|
-
# beside its code: a card for each of its methods, and one for
|
|
10
|
-
# each span of its lines holding sites at the top level; each
|
|
11
|
-
# drawn from the card the JSON report lists, as WithinMethods
|
|
12
|
-
# lists them, each site's row with its tree folded under it.
|
|
13
|
-
# It relies on HtmlReport.located to place each tree's rows in
|
|
14
|
-
# the source.
|
|
15
|
-
module HtmlCards
|
|
16
|
-
# The cards of each method of the file at path, parsed as
|
|
17
|
-
# Manifest.parse gives it; site_paths as Result#paths gives
|
|
18
|
-
# them, reached as Recorder#reached does.
|
|
19
|
-
def self.methods(path, parsed, (site_paths, reached))
|
|
20
|
-
source, sites = parsed.values_at(:source, :sites)
|
|
21
|
-
tree = ->(at, top) { fold(source, sites, site_paths, at, top) }
|
|
22
|
-
recorded = [site_paths, reached]
|
|
23
|
-
cards = WithinMethods.listed_in(path, parsed, *recorded)
|
|
24
|
-
cards.map { |site, card| method_card(site, card, &tree) }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# The Card of the def at site, drawn from card, as
|
|
28
|
-
# WithinMethods.card gives it.
|
|
29
|
-
def self.method_card(site, card, &)
|
|
30
|
-
html = HtmlStatements.card(site, card, &)
|
|
31
|
-
first, column = site.split(':').last(2).map { Integer(_1) }
|
|
32
|
-
status = HtmlStatements.status(card)
|
|
33
|
-
Card.new(first:, last: card['last'], column:, status:,
|
|
34
|
-
top: false, sites: nil, html:)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# A top card for each span of lines holding sites at the top
|
|
38
|
-
# level of the file at path, outside every def, as each
|
|
39
|
-
# span's lines share one button: a row per site in it, as
|
|
40
|
-
# WithinMethods.listed_tops lists them from operands and
|
|
41
|
-
# site_paths.
|
|
42
|
-
def self.tops(path, parsed, (operands, site_paths))
|
|
43
|
-
source, sites = parsed.values_at(:source, :sites)
|
|
44
|
-
tree = ->(at, top) { fold(source, sites, site_paths, at, top) }
|
|
45
|
-
cards = WithinMethods.listed_tops(path, parsed,
|
|
46
|
-
[operands, site_paths])
|
|
47
|
-
cards.map { |site, card| top(site, card, &tree) }
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# The Card of the top card at site, drawn from card.
|
|
51
|
-
def self.top(site, card, &)
|
|
52
|
-
html = HtmlStatements.top_card(site, card, &)
|
|
53
|
-
Card.new(first: card['first'], last: card['last'], column: 0,
|
|
54
|
-
status: HtmlStatements.status(card), top: true,
|
|
55
|
-
sites: card['rows'].size, html:)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# The rows of site's tree, as a file's page draws them, for
|
|
59
|
-
# its row's fold in a card, headed by top, its row's top, eg
|
|
60
|
-
# if/else, so the two always read the same.
|
|
61
|
-
def self.fold(source, sites, site_paths, site, top)
|
|
62
|
-
condition = sites.fetch(site)
|
|
63
|
-
tree = SiteTree.of(source, condition, site_paths.fetch(site))
|
|
64
|
-
located = HtmlReport.located(source, condition, tree)
|
|
65
|
-
else_at = else_at(source, condition)
|
|
66
|
-
HtmlTree.site_rows(located.merge(else_at:, label: top)).join
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# [line, column, line, column] of condition's else keyword in
|
|
70
|
-
# source, so hovering it can open condition's fold, as
|
|
71
|
-
# hovering its if does; nil for one with no else, or one whose
|
|
72
|
-
# else has no code, or a ?:, whose else is no keyword. The
|
|
73
|
-
# keyword is what comes just before its arm's code, so an
|
|
74
|
-
# elsif, or an else with a comment after it, has none.
|
|
75
|
-
def self.else_at(source, condition)
|
|
76
|
-
return nil if condition.operator == '?:'
|
|
77
|
-
|
|
78
|
-
arm = condition.operands.grep(Arm).to_h { [_1.kind, _1] }[:else]
|
|
79
|
-
extent = arm&.extent
|
|
80
|
-
return nil unless extent
|
|
81
|
-
|
|
82
|
-
start = source.b.byteslice(0, extent.begin) =~ /\belse\s*\z/
|
|
83
|
-
return nil unless start
|
|
84
|
-
|
|
85
|
-
HtmlReport.at(source, start...(start + 4))
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|