@@ -40,13 +40,36 @@ class TransformationsExtension {
40
40
// Copy the documentation comments from the fields.
41
41
final docs = [
42
42
'/// ## Parameters' ,
43
- for (final field in fields)
44
- if (field.documentationComment? .split ('.' ).firstOrNull case final comment? )
45
- '/// * [${element .name3 }.${field .name3 }] - ${comment .replaceFirst ('/// ' , '' )}.'
46
- else
47
- '/// * [${element .name3 }.${field .name3 }]' ,
43
+ // for (final field in fields)
44
+ // if (field.documentationComment?.split(RegExp(r'(\. )|\n') ).firstOrNull case final comment?)
45
+ // '/// * [${element.name3}.${field.name3}] - ${comment.replaceFirst('/// ', '')}.'
46
+ // else
47
+ // '/// * [${element.name3}.${field.name3}]',
48
48
];
49
49
50
+ for (final field in fields) {
51
+ final prefix = '/// * [${element .name3 }.${field .name3 }]' ;
52
+ final lines = field.documentationComment? .split ('\n ' ) ?? const < String > [];
53
+
54
+ switch (lines.firstOrNull) {
55
+ case final comment? when comment.startsWith ('/// {@macro' ):
56
+ docs.add ('$prefix - \n $comment ' );
57
+ continue ;
58
+
59
+ case final comment? when comment.startsWith ('/// {@template' ):
60
+ final summary = lines.skip (1 ).join ('\n ' ).replaceFirst ('/// ' , '' ).split ('.' ).firstOrNull;
61
+ final suffix = summary == null ? '' : ' - $summary .' ;
62
+ docs.add ('$prefix $suffix ' );
63
+ continue ;
64
+
65
+ default :
66
+ final summary = field.documentationComment? .replaceFirst ('/// ' , '' ).split ('.' ).firstOrNull;
67
+ final suffix = summary == null ? '' : ' - $summary .' ;
68
+ docs.add ('$prefix $suffix ' );
69
+ continue ;
70
+ }
71
+ }
72
+
50
73
// Generate assignments for the copyWith method body
51
74
final assignments = fields.map ((f) {
52
75
if (nestedMotion (f.type) || nestedStyle (f.type)) {
0 commit comments