designSystemTopic function
The ui_docs answer for topic from ds: design (DESIGN.md),
patterns (PATTERNS.md), tokens, or a component's name (its whole
declaration). Null when topic is none of them.
Implementation
String? designSystemTopic(DesignSystem ds, String topic) {
final t = topic.trim();
final lower = t.toLowerCase();
if (lower == 'design' || lower == 'design.md' || lower == 'principles') return ds.design.isEmpty ? null : ds.design;
if (lower == 'patterns' || lower == 'patterns.md') return ds.patterns.isEmpty ? null : ds.patterns;
if (lower == 'tokens' || lower == 'design-system') return '# ${ds.name}: tokens\n\n${_tokens(ds.tokens)}';
for (final c in ds.list) {
if (c.type == t || c.type.toLowerCase() == lower) return _componentInFull(c);
}
return null;
}