Skip to content

[pigeon] doc comments always start with ' ' #2825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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