(ir: SemanticIR, presentation: ResolvedPresentation)
| 475 | * deciding it in one place keeps the depths from disagreeing about it. |
| 476 | */ |
| 477 | export function visibleSections(ir: SemanticIR, presentation: ResolvedPresentation): TwinSection[] { |
| 478 | const labels = labelsFor(presentation.terminology); |
| 479 | const sections: TwinSection[] = buildSections(ir) |
| 480 | .filter(section => sectionVisible(section.name, presentation.facets)) |
| 481 | .filter(section => section.populated || section.emptyText.length > 0) |
| 482 | .map(section => ({ |
| 483 | ...section, |
| 484 | title: labels[section.name] ?? section.title, |
| 485 | icon: SECTION_ICONS[section.name] |
| 486 | })); |
| 487 | for (const spec of PLACEHOLDER_SECTIONS) { |
| 488 | if (!presentation.facets.has(spec.facet)) { |
| 489 | continue; |
| 490 | } |
| 491 | // A lens with something behind it renders what is behind it. The |
| 492 | // placeholder is the fallback and not the default: a reader who has |
| 493 | // imported a recording must not be told the lens is unbuilt. |
| 494 | const answered = spec.name === 'runtime' ? runtimeSection(ir) : undefined; |
| 495 | sections.push(answered === undefined |
| 496 | ? placeholderSection(spec, labels) |
| 497 | : { ...answered, title: labels[answered.name] ?? answered.title, icon: SECTION_ICONS[answered.name] }); |
| 498 | } |
| 499 | return sections; |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * The same body, with the file's imports folded into the DATA block. |
no test coverage detected