notationGlossary function

List<String> notationGlossary(
  1. DesignSystem designSystem,
  2. NotationVocabulary vocabulary, {
  3. required String prompt,
})

The names designSystem has beyond what the open prompt teaches: its components and the words vocabulary defines in the notation, sorted, leaving out a type of the notation, a page word and any name the prompt already writes (Button, Card, and the define examples' StickyNote).

Implementation

List<String> notationGlossary(DesignSystem designSystem, NotationVocabulary vocabulary, {required String prompt}) {
  final names = {for (final c in designSystem.list) c.type, ...vocabulary.definitions.keys};
  bool taught(String n) =>
      notationTypes.containsKey(n) ||
      PageWords.words.contains(n) ||
      RegExp('(?<![A-Za-z0-9_])${RegExp.escape(n)}(?![A-Za-z0-9_])').hasMatch(prompt);
  return [for (final n in names) if (n.isNotEmpty && n[0] == n[0].toUpperCase() && !taught(n)) n]..sort();
}