Skip to content

Commit 04a5444

Browse files
authored
[pigeon] doc comments always start with ' ' (#2825)
* doc comments always start with ' ' * add unit tests * remove unused import * small test scaffolding fix to allow publish
1 parent 090ebf6 commit 04a5444

File tree

11 files changed

+64
-10
lines changed

11 files changed

+64
-10
lines changed

packages/pigeon/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.2.6
2+
3+
* Fixes bug with parsing documentation comments that start with '/'.
4+
15
## 4.2.5
26

37
* [dart] Fixes enum parameter handling in Dart test API class.

packages/pigeon/lib/generator_tools.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'dart:mirrors';
99
import 'ast.dart';
1010

1111
/// The current version of pigeon. This must match the version in pubspec.yaml.
12-
const String pigeonVersion = '4.2.5';
12+
const String pigeonVersion = '4.2.6';
1313

1414
/// Read all the content from [stdin] to a String.
1515
String readStdin() {
@@ -474,7 +474,10 @@ void addDocumentationComments(
474474
indent.writeln(commentSpec.openCommentToken);
475475
currentLineOpenToken = commentSpec.blockContinuationToken;
476476
}
477-
for (final String line in allComments) {
477+
for (String line in allComments) {
478+
if (line.isNotEmpty && line[0] != ' ') {
479+
line = ' $line';
480+
}
478481
indent.writeln(
479482
'$currentLineOpenToken$line',
480483
);

packages/pigeon/pigeons/message.dart

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import 'package:pigeon/pigeon.dart';
2020
/// This comment is to test enum documentation comments.
2121
///
2222
/// This comment also tests multiple line comments.
23+
///
24+
///////////////////////////
25+
/// This comment also tests comments that start with '/'
26+
///////////////////////////
2327
enum MessageRequestState {
2428
pending,
2529
success,

packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# changes on generated files. This will need a way to avoid unnecessary churn,
33
# such as a flag to suppress version stamp generation.
44
*.java
5-
!AlternateLanguageTestPlugin.kt
5+
!AlternateLanguageTestPlugin.java

packages/pigeon/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: pigeon
22
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
33
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
5-
version: 4.2.5 # This must match the version in lib/generator_tools.dart
5+
version: 4.2.6 # This must match the version in lib/generator_tools.dart
66

77
environment:
88
sdk: ">=2.12.0 <3.0.0"

packages/pigeon/test/cpp_generator_test.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,9 @@ void main() {
10621062
];
10631063
int count = 0;
10641064

1065+
final List<String> unspacedComments = <String>['////////'];
1066+
int unspacedCount = 0;
1067+
10651068
final Root root = Root(
10661069
apis: <Api>[
10671070
Api(
@@ -1107,7 +1110,10 @@ void main() {
11071110
enums: <Enum>[
11081111
Enum(
11091112
name: 'enum',
1110-
documentationComments: <String>[comments[count++]],
1113+
documentationComments: <String>[
1114+
comments[count++],
1115+
unspacedComments[unspacedCount++]
1116+
],
11111117
members: <String>[
11121118
'one',
11131119
'two',
@@ -1121,6 +1127,7 @@ void main() {
11211127
for (final String comment in comments) {
11221128
expect(code, contains('//$comment'));
11231129
}
1130+
expect(code, contains('// ///'));
11241131
});
11251132

11261133
test('doesnt create codecs if no custom datatypes', () {

packages/pigeon/test/dart_generator_test.dart

+9-1
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,10 @@ name: foobar
11741174
' enum comment',
11751175
];
11761176
int count = 0;
1177+
1178+
final List<String> unspacedComments = <String>['////////'];
1179+
int unspacedCount = 0;
1180+
11771181
final Root root = Root(
11781182
apis: <Api>[
11791183
Api(
@@ -1219,7 +1223,10 @@ name: foobar
12191223
enums: <Enum>[
12201224
Enum(
12211225
name: 'enum',
1222-
documentationComments: <String>[comments[count++]],
1226+
documentationComments: <String>[
1227+
comments[count++],
1228+
unspacedComments[unspacedCount++]
1229+
],
12231230
members: <String>[
12241231
'one',
12251232
'two',
@@ -1233,6 +1240,7 @@ name: foobar
12331240
for (final String comment in comments) {
12341241
expect(code, contains('///$comment'));
12351242
}
1243+
expect(code, contains('/// ///'));
12361244
});
12371245

12381246
test('doesnt create codecs if no custom datatypes', () {

packages/pigeon/test/java_generator_test.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,9 @@ void main() {
11391139
];
11401140
int count = 0;
11411141

1142+
final List<String> unspacedComments = <String>['////////'];
1143+
int unspacedCount = 0;
1144+
11421145
final Root root = Root(
11431146
apis: <Api>[
11441147
Api(
@@ -1185,7 +1188,10 @@ void main() {
11851188
enums: <Enum>[
11861189
Enum(
11871190
name: 'enum',
1188-
documentationComments: <String>[comments[count++]],
1191+
documentationComments: <String>[
1192+
comments[count++],
1193+
unspacedComments[unspacedCount++]
1194+
],
11891195
members: <String>[
11901196
'one',
11911197
'two',
@@ -1204,6 +1210,7 @@ void main() {
12041210
.hasMatch(code),
12051211
true);
12061212
}
1213+
expect(code, isNot(contains('*//')));
12071214
});
12081215

12091216
test('doesnt create codecs if no custom datatypes', () {

packages/pigeon/test/kotlin_generator_test.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,9 @@ void main() {
10191019
];
10201020
int count = 0;
10211021

1022+
final List<String> unspacedComments = <String>['////////'];
1023+
int unspacedCount = 0;
1024+
10221025
final Root root = Root(
10231026
apis: <Api>[
10241027
Api(
@@ -1065,7 +1068,10 @@ void main() {
10651068
enums: <Enum>[
10661069
Enum(
10671070
name: 'enum',
1068-
documentationComments: <String>[comments[count++]],
1071+
documentationComments: <String>[
1072+
comments[count++],
1073+
unspacedComments[unspacedCount++]
1074+
],
10691075
members: <String>[
10701076
'one',
10711077
'two',
@@ -1084,6 +1090,7 @@ void main() {
10841090
.hasMatch(code),
10851091
true);
10861092
}
1093+
expect(code, isNot(contains('*//')));
10871094
});
10881095

10891096
test('doesnt create codecs if no custom datatypes', () {

packages/pigeon/test/objc_generator_test.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,9 @@ void main() {
17511751
];
17521752
int count = 0;
17531753

1754+
final List<String> unspacedComments = <String>['////////'];
1755+
int unspacedCount = 0;
1756+
17541757
final Root root = Root(
17551758
apis: <Api>[
17561759
Api(
@@ -1797,7 +1800,10 @@ void main() {
17971800
enums: <Enum>[
17981801
Enum(
17991802
name: 'enum',
1800-
documentationComments: <String>[comments[count++]],
1803+
documentationComments: <String>[
1804+
comments[count++],
1805+
unspacedComments[unspacedCount++]
1806+
],
18011807
members: <String>[
18021808
'one',
18031809
'two',
@@ -1811,6 +1817,7 @@ void main() {
18111817
for (final String comment in comments) {
18121818
expect(code, contains('///$comment'));
18131819
}
1820+
expect(code, contains('/// ///'));
18141821
});
18151822

18161823
test('doesnt create codecs if no custom datatypes', () {

packages/pigeon/test/swift_generator_test.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,9 @@ void main() {
958958
];
959959
int count = 0;
960960

961+
final List<String> unspacedComments = <String>['////////'];
962+
int unspacedCount = 0;
963+
961964
final Root root = Root(
962965
apis: <Api>[
963966
Api(
@@ -1004,7 +1007,10 @@ void main() {
10041007
enums: <Enum>[
10051008
Enum(
10061009
name: 'enum',
1007-
documentationComments: <String>[comments[count++]],
1010+
documentationComments: <String>[
1011+
comments[count++],
1012+
unspacedComments[unspacedCount++]
1013+
],
10081014
members: <String>[
10091015
'one',
10101016
'two',
@@ -1019,6 +1025,7 @@ void main() {
10191025
for (final String comment in comments) {
10201026
expect(code, contains('///$comment'));
10211027
}
1028+
expect(code, contains('/// ///'));
10221029
});
10231030

10241031
test('doesnt create codecs if no custom datatypes', () {

0 commit comments

Comments
 (0)