Skip to content

Commit

Permalink
[pigeon] doc comments always start with ' ' (#2825)
Browse files Browse the repository at this point in the history
* doc comments always start with ' '

* add unit tests

* remove unused import

* small test scaffolding fix to allow publish
  • Loading branch information
tarrinneal committed Nov 19, 2022
1 parent 090ebf6 commit 04a5444
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 10 deletions.
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
@@ -1,3 +1,7 @@
## 4.2.6

* Fixes bug with parsing documentation comments that start with '/'.

## 4.2.5

* [dart] Fixes enum parameter handling in Dart test API class.
Expand Down
7 changes: 5 additions & 2 deletions packages/pigeon/lib/generator_tools.dart
Expand Up @@ -9,7 +9,7 @@ import 'dart:mirrors';
import 'ast.dart';

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

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down Expand Up @@ -474,7 +474,10 @@ void addDocumentationComments(
indent.writeln(commentSpec.openCommentToken);
currentLineOpenToken = commentSpec.blockContinuationToken;
}
for (final String line in allComments) {
for (String line in allComments) {
if (line.isNotEmpty && line[0] != ' ') {
line = ' $line';
}
indent.writeln(
'$currentLineOpenToken$line',
);
Expand Down
4 changes: 4 additions & 0 deletions packages/pigeon/pigeons/message.dart
Expand Up @@ -20,6 +20,10 @@ import 'package:pigeon/pigeon.dart';
/// This comment is to test enum documentation comments.
///
/// This comment also tests multiple line comments.
///
///////////////////////////
/// This comment also tests comments that start with '/'
///////////////////////////
enum MessageRequestState {
pending,
success,
Expand Down
Expand Up @@ -2,4 +2,4 @@
# changes on generated files. This will need a way to avoid unnecessary churn,
# such as a flag to suppress version stamp generation.
*.java
!AlternateLanguageTestPlugin.kt
!AlternateLanguageTestPlugin.java
2 changes: 1 addition & 1 deletion packages/pigeon/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: pigeon
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
version: 4.2.5 # This must match the version in lib/generator_tools.dart
version: 4.2.6 # This must match the version in lib/generator_tools.dart

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
9 changes: 8 additions & 1 deletion packages/pigeon/test/cpp_generator_test.dart
Expand Up @@ -1062,6 +1062,9 @@ void main() {
];
int count = 0;

final List<String> unspacedComments = <String>['////////'];
int unspacedCount = 0;

final Root root = Root(
apis: <Api>[
Api(
Expand Down Expand Up @@ -1107,7 +1110,10 @@ void main() {
enums: <Enum>[
Enum(
name: 'enum',
documentationComments: <String>[comments[count++]],
documentationComments: <String>[
comments[count++],
unspacedComments[unspacedCount++]
],
members: <String>[
'one',
'two',
Expand All @@ -1121,6 +1127,7 @@ void main() {
for (final String comment in comments) {
expect(code, contains('//$comment'));
}
expect(code, contains('// ///'));
});

test('doesnt create codecs if no custom datatypes', () {
Expand Down
10 changes: 9 additions & 1 deletion packages/pigeon/test/dart_generator_test.dart
Expand Up @@ -1174,6 +1174,10 @@ name: foobar
' enum comment',
];
int count = 0;

final List<String> unspacedComments = <String>['////////'];
int unspacedCount = 0;

final Root root = Root(
apis: <Api>[
Api(
Expand Down Expand Up @@ -1219,7 +1223,10 @@ name: foobar
enums: <Enum>[
Enum(
name: 'enum',
documentationComments: <String>[comments[count++]],
documentationComments: <String>[
comments[count++],
unspacedComments[unspacedCount++]
],
members: <String>[
'one',
'two',
Expand All @@ -1233,6 +1240,7 @@ name: foobar
for (final String comment in comments) {
expect(code, contains('///$comment'));
}
expect(code, contains('/// ///'));
});

test('doesnt create codecs if no custom datatypes', () {
Expand Down
9 changes: 8 additions & 1 deletion packages/pigeon/test/java_generator_test.dart
Expand Up @@ -1139,6 +1139,9 @@ void main() {
];
int count = 0;

final List<String> unspacedComments = <String>['////////'];
int unspacedCount = 0;

final Root root = Root(
apis: <Api>[
Api(
Expand Down Expand Up @@ -1185,7 +1188,10 @@ void main() {
enums: <Enum>[
Enum(
name: 'enum',
documentationComments: <String>[comments[count++]],
documentationComments: <String>[
comments[count++],
unspacedComments[unspacedCount++]
],
members: <String>[
'one',
'two',
Expand All @@ -1204,6 +1210,7 @@ void main() {
.hasMatch(code),
true);
}
expect(code, isNot(contains('*//')));
});

test('doesnt create codecs if no custom datatypes', () {
Expand Down
9 changes: 8 additions & 1 deletion packages/pigeon/test/kotlin_generator_test.dart
Expand Up @@ -1019,6 +1019,9 @@ void main() {
];
int count = 0;

final List<String> unspacedComments = <String>['////////'];
int unspacedCount = 0;

final Root root = Root(
apis: <Api>[
Api(
Expand Down Expand Up @@ -1065,7 +1068,10 @@ void main() {
enums: <Enum>[
Enum(
name: 'enum',
documentationComments: <String>[comments[count++]],
documentationComments: <String>[
comments[count++],
unspacedComments[unspacedCount++]
],
members: <String>[
'one',
'two',
Expand All @@ -1084,6 +1090,7 @@ void main() {
.hasMatch(code),
true);
}
expect(code, isNot(contains('*//')));
});

test('doesnt create codecs if no custom datatypes', () {
Expand Down
9 changes: 8 additions & 1 deletion packages/pigeon/test/objc_generator_test.dart
Expand Up @@ -1751,6 +1751,9 @@ void main() {
];
int count = 0;

final List<String> unspacedComments = <String>['////////'];
int unspacedCount = 0;

final Root root = Root(
apis: <Api>[
Api(
Expand Down Expand Up @@ -1797,7 +1800,10 @@ void main() {
enums: <Enum>[
Enum(
name: 'enum',
documentationComments: <String>[comments[count++]],
documentationComments: <String>[
comments[count++],
unspacedComments[unspacedCount++]
],
members: <String>[
'one',
'two',
Expand All @@ -1811,6 +1817,7 @@ void main() {
for (final String comment in comments) {
expect(code, contains('///$comment'));
}
expect(code, contains('/// ///'));
});

test('doesnt create codecs if no custom datatypes', () {
Expand Down
9 changes: 8 additions & 1 deletion packages/pigeon/test/swift_generator_test.dart
Expand Up @@ -958,6 +958,9 @@ void main() {
];
int count = 0;

final List<String> unspacedComments = <String>['////////'];
int unspacedCount = 0;

final Root root = Root(
apis: <Api>[
Api(
Expand Down Expand Up @@ -1004,7 +1007,10 @@ void main() {
enums: <Enum>[
Enum(
name: 'enum',
documentationComments: <String>[comments[count++]],
documentationComments: <String>[
comments[count++],
unspacedComments[unspacedCount++]
],
members: <String>[
'one',
'two',
Expand All @@ -1019,6 +1025,7 @@ void main() {
for (final String comment in comments) {
expect(code, contains('///$comment'));
}
expect(code, contains('/// ///'));
});

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

0 comments on commit 04a5444

Please sign in to comment.