Skip to content

Commit 09ef603

Browse files
committed
docs(quoteforge[warnings]): document why handledBlockTypes parses the template source
1 parent b2e17e5 commit 09ef603

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/renderer/template-warnings.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ function templateSource(template: string): string {
2424
}
2525
}
2626

27+
/**
28+
* The block types a template actually renders, read from its own `block.type ==`
29+
* guards so the answer cannot drift from the markup. Every shipped template
30+
* dispatches this way and none has a catch-all `{% else %}`, so a type absent
31+
* here is genuinely dropped. Scanning the whole file rather than a single loop
32+
* keeps the set over-permissive on purpose: a missed warning costs less than one
33+
* that cries about a card which renders fine.
34+
*
35+
* Returns undefined when the template is unknown or dispatches some other way —
36+
* callers stay quiet rather than guess.
37+
*/
2738
function handledBlockTypes(template: string): Set<string> | undefined {
2839
const matches = templateSource(template).matchAll(/block\.type\s*==\s*"([a-z-]+)"/g);
2940
const types = new Set([...matches].map((m) => m[1] as string));

0 commit comments

Comments
 (0)