applyDescription method
Adds a tagged documentation description (/// @description ...) to schema.
Analyzer does not attach parameter doc comments to parameter elements. A function generator passes the comment from its source AST.
Implementation
String applyDescription(
String schema,
Element declaration, {
String? sourceComment,
}) {
final String? description;
try {
description = parseDescriptionTag(
sourceComment ?? declaration.documentationComment,
);
} on FormatException catch (error) {
throw InvalidGenerationSource(
'${declaration.name} ${error.message}',
element: declaration,
);
}
return description == null
? schema
: '$schema.describe(${dartStringLiteral(description)})';
}