(ir: SemanticIR, presentation: ResolvedPresentation)
| 1268 | } |
| 1269 | |
| 1270 | function narrative(ir: SemanticIR, presentation: ResolvedPresentation): TwinViewModel { |
| 1271 | const facets = presentation.facets; |
| 1272 | const paragraphs = [overviewClauses(ir, facets).join(' ')]; |
| 1273 | const notes: string[] = []; |
| 1274 | // The paragraph above was assembled from counts, and a reader who cannot |
| 1275 | // see the sections cannot see that for themselves. |
| 1276 | if (facets.has(Facet.Logic)) { |
| 1277 | notes.push(PROSE_GENERATED_NOTE); |
| 1278 | } |
| 1279 | |
| 1280 | const showCallees = facets.has(Facet.Logic) || facets.has(Facet.Calls); |
| 1281 | const { chips, hidden } = showCallees ? proseChips(ir, MAX_PROSE_CHIPS) : { chips: [], hidden: 0 }; |
| 1282 | if (chips.length > 0) { |
| 1283 | paragraphs.push(PROSE_CHIPS_LEAD); |
| 1284 | } |
| 1285 | if (hidden > 0) { |
| 1286 | notes.push(proseMoreParts(hidden)); |
| 1287 | } |
| 1288 | if (facets.has(Facet.Errors)) { |
| 1289 | const note = errorsNote(ir); |
| 1290 | if (note.length > 0) { |
| 1291 | notes.push(note); |
| 1292 | } |
| 1293 | } |
| 1294 | if (facets.has(Facet.Tests)) { |
| 1295 | const note = testsNote(ir); |
| 1296 | if (note.length > 0) { |
| 1297 | notes.push(note); |
| 1298 | } |
| 1299 | } |
| 1300 | for (const spec of PLACEHOLDER_SECTIONS) { |
| 1301 | if (!facets.has(spec.facet)) { |
| 1302 | continue; |
| 1303 | } |
| 1304 | // The same rule the section list follows: a lens with an answer says its |
| 1305 | // answer, and only a lens with none says it has none. At this depth the |
| 1306 | // answer is a count and never a list of identifiers, which is what the |
| 1307 | // narrative depth is for. |
| 1308 | const answered = spec.name === 'runtime' ? runtimeSection(ir) : undefined; |
| 1309 | notes.push(answered === undefined |
| 1310 | ? spec.sentence |
| 1311 | : (answered.text ?? answered.emptyText)); |
| 1312 | } |
| 1313 | return { |
| 1314 | ...emptyModel(ir, presentation, 'prose'), |
| 1315 | paragraphs, |
| 1316 | chips, |
| 1317 | notes, |
| 1318 | rewritable: readerLines([ |
| 1319 | ...paragraphs.map((text, index) => ({ id: `p${index}`, text })), |
| 1320 | ...notes.map((text, index) => ({ id: `n${index}`, text })) |
| 1321 | ]) |
| 1322 | }; |
| 1323 | } |
| 1324 | |
| 1325 | /** |
| 1326 | * Everything this model puts in front of a reader, as one string. |
no test coverage detected