Switch document generation to use the snippets package (#87231)
Switch document generation to use the snippets package instead of the snippets code in the Flutter repo. In the process, some bugs in sample code analysis have been fixed, and I've fixed some more errors in the samples. This will allow the snippets package to be developed separately from the Flutter repo, and reduce the code in the Flutter repo. The snippets code is deleted in this PR. I also converted some comments in the snippet templates to be regular comments instead of doc comments, because having a doc comment block before the imports causes the Dart import sorter to lose the comment. They should have been regular comments in the first place. The snippets package resides in the assets-for-api-docs repo. The sample analysis has also been converted to be run in parallel, and I've bumped the Dartdoc version to 1.0.2.
This commit is contained in:
@@ -11,11 +11,13 @@ library dart.ui;
|
||||
/// Annotation used by Flutter's Dart compiler to indicate that an
|
||||
/// [Object.toString] override should not be replaced with a supercall.
|
||||
///
|
||||
/// {@tool sample}
|
||||
/// {@tool sample --template=stateless_widget_material}
|
||||
/// A sample if using keepToString to prevent replacement by a supercall.
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyStringBuffer {
|
||||
/// error;
|
||||
///
|
||||
/// StringBuffer _buffer = StringBuffer();
|
||||
///
|
||||
/// @keepToString
|
||||
|
||||
@@ -20,11 +20,10 @@ void main() {
|
||||
<String>['analyze_sample_code.dart', '--no-include-dart-ui', 'test/analyze-sample-code-test-input'],
|
||||
);
|
||||
final List<String> stdoutLines = process.stdout.toString().split('\n');
|
||||
final List<String> stderrLines = process.stderr.toString().split('\n')
|
||||
..removeWhere((String line) => line.startsWith('Analyzer output:') || line.startsWith('Building flutter tool...'));
|
||||
final List<String> stderrLines = process.stderr.toString().split('\n');
|
||||
expect(process.exitCode, isNot(equals(0)));
|
||||
expect(stderrLines, <String>[
|
||||
'In sample starting at dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:125: child: Text(title),',
|
||||
expect(stderrLines, containsAll(<String>[
|
||||
'In sample starting at dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:125: child: Text(title),',
|
||||
">>> error: The final variable 'title' can't be read because it is potentially unassigned at this point (read_potentially_unassigned_final)",
|
||||
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:30:9: new Opacity(',
|
||||
'>>> info: Unnecessary new keyword (unnecessary_new)',
|
||||
@@ -38,32 +37,35 @@ void main() {
|
||||
">>> error: A value of type 'Null' can't be assigned to a variable of type 'int' (invalid_assignment)",
|
||||
'dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart:120:24: const SizedBox(),',
|
||||
'>>> error: Unexpected comma at end of sample code. (missing_identifier)',
|
||||
'',
|
||||
'Found 2 sample code errors.',
|
||||
''
|
||||
]);
|
||||
expect(stdoutLines, <String>[
|
||||
]));
|
||||
expect(stdoutLines, containsAll(<String>[
|
||||
'Found 9 snippet code blocks, 0 sample code sections, and 2 dartpad sections.',
|
||||
'Starting analysis of code samples.',
|
||||
'',
|
||||
]);
|
||||
]));
|
||||
});
|
||||
test('Analyzes dart:ui code', () {
|
||||
final ProcessResult process = Process.runSync(
|
||||
'../../bin/cache/dart-sdk/bin/dart',
|
||||
<String>[
|
||||
'analyze_sample_code.dart',
|
||||
'--dart-ui-location',
|
||||
'test/analyze-sample-code-test-dart-ui',
|
||||
'--dart-ui-location=test/analyze-sample-code-test-dart-ui',
|
||||
'test/analyze-sample-code-test-input',
|
||||
],
|
||||
);
|
||||
final List<String> stdoutLines = process.stdout.toString().split('\n');
|
||||
final List<String> stderrLines = process.stderr.toString().split('\n');
|
||||
expect(process.exitCode, isNot(equals(0)));
|
||||
expect(stdoutLines, equals(<String>[
|
||||
expect(stderrLines, containsAll(<String>[
|
||||
'In sample starting at dev/bots/test/analyze-sample-code-test-dart-ui/ui.dart:15:class MyStatelessWidget extends StatelessWidget {',
|
||||
">>> error: Missing concrete implementation of 'StatelessWidget.build' (non_abstract_class_inherits_abstract_member)",
|
||||
'In sample starting at dev/bots/test/analyze-sample-code-test-dart-ui/ui.dart:15:class MyStringBuffer {',
|
||||
">>> error: Classes can't be declared inside other classes (class_in_class)",
|
||||
]));
|
||||
expect(stdoutLines, containsAll(<String>[
|
||||
// There is one sample code section in the test's dummy dart:ui code.
|
||||
'Found 9 snippet code blocks, 1 sample code sections, and 2 dartpad sections.',
|
||||
'',
|
||||
'Starting analysis of code samples.',
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user