[flutter_plugin_tools] Reimplements the excerpt system inline in the tool, rather than relying on a separate package. (#4417)

* Allows excerpts to come from any package, not just examples.
* Fixes a bug in the excerpting logic that was causing a stray `}` to appear in one example.
* Removes the need for `build.excerpt.yaml` files.
* Remove the dependency on build_runner for excerpts.
* Reduces the time to generate the excerpts from about 10 minutes to about 5 seconds.
* Almost certainly fixes https://github.com/flutter/flutter/issues/107180 (untested).

The new logic is not quite backwards compatible; the `path-base` feature now specifies a real path to the actual source directories, rather than a path into the invisible generated `excerpts/` directory with its special structure. Also, a number of features from the previous package that were not actually used in this repository are no longer supported (such as having multiple section names per `#docregion` pragma).
This commit is contained in:
Ian Hickson
2023-07-11 14:49:24 -07:00
committed by GitHub
parent e479ca5d82
commit bd5d19113e
45 changed files with 749 additions and 1080 deletions

View File

@ -648,7 +648,6 @@ A B C
final RepositoryPackage package = createFakePackage(
'a_package',
packagesDir,
extraFiles: <String>[kReadmeExcerptConfigPath],
);
package.readmeFile.writeAsStringSync('''
@ -672,40 +671,6 @@ A B C
);
});
test('fails when excerpts are used but the package is not configured',
() async {
final RepositoryPackage package =
createFakePackage('a_package', packagesDir);
package.readmeFile.writeAsStringSync('''
Example:
<?code-excerpt "main.dart (SomeSection)"?>
```dart
A B C
```
''');
Error? commandError;
final List<String> output = await runCapturingPrint(
runner, <String>['readme-check', '--require-excerpts'],
errorHandler: (Error e) {
commandError = e;
});
expect(commandError, isA<ToolExit>());
expect(
output,
containsAllInOrder(<Matcher>[
contains('code-excerpt tag found, but the package is not configured '
'for excerpting. Follow the instructions at\n'
'https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages\n'
'for setting up a build.excerpt.yaml file.'),
contains('Missing code-excerpt configuration'),
]),
);
});
test('fails on missing excerpt tag when requested', () async {
final RepositoryPackage package =
createFakePackage('a_package', packagesDir);