describeTypes function
What ui_read {"types": [...]} answers: each node type's children and
slots, whether it takes a decoration, and its props (type and doc).
Implementation
Json describeTypes(Catalog catalog, Iterable<String> types) => {
for (final t in types)
t: switch (catalog.widget(t)) {
null => {
'error': 'Not a node type here. Types: ${[for (final w in catalog.widgets) w.type].join(', ')}.',
},
final w => {
'children': w.children.name,
if (w.slots.isNotEmpty) 'slots': w.slots,
'decoration': w.decorated,
if (w.doc.isNotEmpty) 'doc': firstSentences(w.doc, 2),
'props': {
for (final p in w.props)
p.key: '${propTypeLabel(p.type)}${p.doc.isEmpty ? '' : ': ${firstSentences(p.doc, 1)}'}',
},
},
},
};