Skip to content

Commit ecbc9aa

Browse files
authored
Make old code excerpter ignore new <?code-excerpt?> blocks (#2234)
... w/o the need for <!-- skip --> comments. Contributes to #2233
1 parent c6034e6 commit ecbc9aa

File tree

3 files changed

+1
-12
lines changed

3 files changed

+1
-12
lines changed

src/docs/development/ui/layout/tutorial.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ Since the code for building each row is almost identical, create a private
204204
helper method named `buildButtonColumn()`, which takes a color, an Icon and
205205
Text, and returns a column with its widgets painted in the given color.
206206

207-
<!-- skip -->
208207
<?code-excerpt "lib/main.dart (_buildButtonColumn)" title?>
209208
```dart
210209
class MyApp extends StatelessWidget {
@@ -245,7 +244,6 @@ using `MainAxisAlignment.spaceEvenly` to arrange the free space evenly before,
245244
between, and after each column. Add the following code just below the
246245
`titleSection` declaration inside the `build()` method:
247246

248-
<!-- skip -->
249247
<?code-excerpt "lib/main.dart (buttonSection)" title?>
250248
```dart
251249
Color color = Theme.of(context).primaryColor;
@@ -293,7 +291,6 @@ Define the text section as a variable. Put the text in a Container and add
293291
padding along each edge. Add the following code just below the `buttonSection`
294292
declaration:
295293

296-
<!-- skip -->
297294
<?code-excerpt "lib/main.dart (textSection)" title?>
298295
```dart
299296
Widget textSection = Container(

src/docs/get-started/codelab.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ packages, on [the Package site](https://pub.dartlang.org/flutter).
210210
211211
3. In `lib/main.dart`, import the new package:
212212
213-
<!-- skip -->
214213
<?code-excerpt path-base="codelabs/startup_namer/step2_use_package"?>
215214
<?code-excerpt "lib/main.dart" title retain="/^import/" replace="/import.*?english.*/[!$&!]/g" indent-by="2"?>
216215
```dart
@@ -299,7 +298,6 @@ a child inside the existing `MyApp` stateless widget.
299298
1. Create a minimal state class. Add the following to the bottom
300299
of `main.dart`:
301300
302-
<!-- skip -->
303301
<?code-excerpt "lib/main.dart (RandomWordsState)" title region="RWS-class-only" plaster="// TODO Add build() method" indent-by="2"?>
304302
```dart
305303
class RandomWordsState extends State<RandomWords> {
@@ -322,7 +320,6 @@ a child inside the existing `MyApp` stateless widget.
322320
2. Add the stateful `RandomWords` widget to `main.dart`.
323321
The `RandomWords` widget does little else beside creating its State class:
324322
325-
<!-- skip -->
326323
<?code-excerpt "lib/main.dart (RandomWords)" title indent-by="2"?>
327324
```dart
328325
class RandomWords extends StatefulWidget {
@@ -338,7 +335,6 @@ a child inside the existing `MyApp` stateless widget.
338335
339336
3. Add the `build()` method to `RandomWordsState`:
340337
341-
<!-- skip -->
342338
<?code-excerpt "lib/main.dart (RandomWordsState)" title indent-by="2" replace="/(\n )(.*)/$1[!$2!]/g"?>
343339
```dart
344340
class RandomWordsState extends State<RandomWords> {
@@ -418,7 +414,6 @@ lazily, on demand.
418414
class for saving suggested word pairings.
419415
Also, add a `_biggerFont` variable for making the font size larger.
420416
421-
<!-- skip -->
422417
<?code-excerpt "lib/main.dart" title region="RWS-var" indent-by="2" replace="/final .*/[!$&!]/g"?>
423418
```dart
424419
class RandomWordsState extends State<RandomWords> {
@@ -448,7 +443,6 @@ lazily, on demand.
448443
449444
2. Add a `_buildSuggestions()` function to the `RandomWordsState` class:
450445
451-
<!-- skip -->
452446
<?code-excerpt "lib/main.dart (_buildSuggestions)" title indent-by="2"?>
453447
```dart
454448
Widget _buildSuggestions() {
@@ -486,7 +480,6 @@ lazily, on demand.
486480
487481
3. Add a `_buildRow()` function to `RandomWordsState`:
488482
489-
<!-- skip -->
490483
<?code-excerpt "lib/main.dart (_buildRow)" title indent-by="2"?>
491484
```dart
492485
Widget _buildRow(WordPair pair) {
@@ -506,7 +499,6 @@ lazily, on demand.
506499
implements the basic Material Design visual layout.)
507500
Replace the method body with the highlighted code:
508501
509-
<!-- skip -->
510502
<?code-excerpt "lib/main.dart (build)" title region="RWS-build" replace="/(\n )(return.*| .*|\);)/$1[!$2!]/g" indent-by="2"?>
511503
```dart
512504
@override

tool/extract.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int _processFile(File file) {
6767
}
6868
lastComment = lastComment.substring(0, lastComment.length - 3);
6969
} else if (lines[index].contains('<?code-') || lines[index].trim().isEmpty) {
70-
// Carry on. In particular, don't reset lastComment.
70+
lastComment = 'skip';
7171
} else {
7272
lastComment = null;
7373
}

0 commit comments

Comments
 (0)