Skip to content
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

Speed up code excerpt updater #10383

Merged
merged 1 commit into from
Apr 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TakePictureScreen extends StatefulWidget {

class TakePictureScreenState extends State<TakePictureScreen> {
late CameraController _controller;
// ignore_for_file: unused_field
// ignore: unused_field
late Future<void> _initializeControllerFuture;

@override
Expand Down
2 changes: 1 addition & 1 deletion src/content/cookbook/plugins/picture-using-camera.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ and display a preview of the camera's feed.
4. Create and initialize the controller in the `initState()` method.
5. Dispose of the controller in the `dispose()` method.

<?code-excerpt "lib/main_step3.dart (controller)"?>
<?code-excerpt "lib/main_step3.dart (controller)" remove="ignore:"?>
```dart
// A screen that allows users to take a picture using a given camera.
class TakePictureScreen extends StatefulWidget {
Expand Down
21 changes: 1 addition & 20 deletions tool/flutter_site/lib/src/commands/refresh_excerpts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,7 @@ Future<int> _refreshExcerpts({
return 1;
}

// A collection of replacements for the code excerpt updater tool
// to run by default.
// They must not contain (unencoded/unescaped) spaces.
const replacements = [
// Allows use of //!<br> to force a line break (against dart format)
r'/\/\/!<br>//g;',
// Replace commented out ellipses: /*...*/ --> ...
r'/\/\*(\s*\.\.\.\s*)\*\//$1/g;',
// Replace brackets with commented out ellipses: {/*-...-*/} --> ...
r'/\{\/\*-(\s*\.\.\.\s*)-\*\/\}/$1/g;',
// Remove markers declaring an analysis issue or runtime error.
r'/\/\/!(analysis-issue|runtime-error)[^\n]*//g;',
// Remove analyzer ignore for file markers.
r'/\x20*\/\/\s+ignore_for_file:[^\n]+\n//g;',
// Remove analyzer inline ignores.
r'/\x20*\/\/\s+ignore:[^\n]+//g;',
];

final srcDirectoryPath = path.join(repositoryRoot, 'src');
final srcDirectoryPath = path.join(repositoryRoot, 'src', 'content');
final updaterArguments = <String>[
'--fragment-dir-path',
path.join(fragments, 'examples'),
Expand All @@ -148,7 +130,6 @@ Future<int> _refreshExcerpts({
if (verboseLogging) '--log-fine',
'--yaml',
'--no-escape-ng-interpolation',
'--replace=${replacements.join('')}',
'--write-in-place',
srcDirectoryPath,
];
Expand Down
Loading