-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate docs of enums and rpc clients, some refactoring (#909)
This implements generating doc comments for enum types, enum values, rpc types, and rpc methods. Existing code for generating doc comments is refactored: the comment generator handles trailing whitespace so we don't have to handle it in the call sites. Comment generator is documented with the invariants: it never returns an empty string (returns `null` instead) and never returns lines with trailing whitespace. To be able to test comment generating, a new kind of golden file test is added. The difference from the other golden file tests is that this file is compiled from .proto source instead of from a hand-crafted descriptor. This is because attaching comments to proto field and types by hand is difficult and error prone. Fixes the comment part of #900.
- Loading branch information
Showing
11 changed files
with
315 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
import 'golden_file.dart'; | ||
|
||
void main() { | ||
test('Doc comment generation for messages', () { | ||
final actual = File('out/protos/doc_comments.pb.dart').readAsStringSync(); | ||
expectMatchesGoldenFile(actual, 'test/goldens/doc_comments'); | ||
}); | ||
|
||
test('Doc comment generation for enums', () { | ||
final actual = File('out/protos/constructor_args/doc_comments.pbenum.dart') | ||
.readAsStringSync(); | ||
expectMatchesGoldenFile(actual, 'test/goldens/doc_comments.pbenum'); | ||
}); | ||
} |
Oops, something went wrong.