Skip to content

Commit

Permalink
Make old code excerpter ignore new <?code-excerpt?> blocks
Browse files Browse the repository at this point in the history
... w/o the need for <!-- skip --> comments. Contributes to #2233
  • Loading branch information
chalin committed Jan 17, 2019
1 parent c6034e6 commit 15ddba0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 12 deletions.
3 changes: 0 additions & 3 deletions src/docs/development/ui/layout/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ Since the code for building each row is almost identical, create a private
helper method named `buildButtonColumn()`, which takes a color, an Icon and
Text, and returns a column with its widgets painted in the given color.

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

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

<!-- skip -->
<?code-excerpt "lib/main.dart (textSection)" title?>
```dart
Widget textSection = Container(
Expand Down
8 changes: 0 additions & 8 deletions src/docs/get-started/codelab.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ packages, on [the Package site](https://pub.dartlang.org/flutter).

3. In `lib/main.dart`, import the new package:

<!-- skip -->
<?code-excerpt path-base="codelabs/startup_namer/step2_use_package"?>
<?code-excerpt "lib/main.dart" title retain="/^import/" replace="/import.*?english.*/[!$&!]/g" indent-by="2"?>
```dart
Expand Down Expand Up @@ -299,7 +298,6 @@ a child inside the existing `MyApp` stateless widget.
1. Create a minimal state class. Add the following to the bottom
of `main.dart`:

<!-- skip -->
<?code-excerpt "lib/main.dart (RandomWordsState)" title region="RWS-class-only" plaster="// TODO Add build() method" indent-by="2"?>
```dart
class RandomWordsState extends State<RandomWords> {
Expand All @@ -322,7 +320,6 @@ a child inside the existing `MyApp` stateless widget.
2. Add the stateful `RandomWords` widget to `main.dart`.
The `RandomWords` widget does little else beside creating its State class:

<!-- skip -->
<?code-excerpt "lib/main.dart (RandomWords)" title indent-by="2"?>
```dart
class RandomWords extends StatefulWidget {
Expand All @@ -338,7 +335,6 @@ a child inside the existing `MyApp` stateless widget.

3. Add the `build()` method to `RandomWordsState`:

<!-- skip -->
<?code-excerpt "lib/main.dart (RandomWordsState)" title indent-by="2" replace="/(\n )(.*)/$1[!$2!]/g"?>
```dart
class RandomWordsState extends State<RandomWords> {
Expand Down Expand Up @@ -418,7 +414,6 @@ lazily, on demand.
class for saving suggested word pairings.
Also, add a `_biggerFont` variable for making the font size larger.

<!-- skip -->
<?code-excerpt "lib/main.dart" title region="RWS-var" indent-by="2" replace="/final .*/[!$&!]/g"?>
```dart
class RandomWordsState extends State<RandomWords> {
Expand Down Expand Up @@ -448,7 +443,6 @@ lazily, on demand.

2. Add a `_buildSuggestions()` function to the `RandomWordsState` class:

<!-- skip -->
<?code-excerpt "lib/main.dart (_buildSuggestions)" title indent-by="2"?>
```dart
Widget _buildSuggestions() {
Expand Down Expand Up @@ -486,7 +480,6 @@ lazily, on demand.

3. Add a `_buildRow()` function to `RandomWordsState`:

<!-- skip -->
<?code-excerpt "lib/main.dart (_buildRow)" title indent-by="2"?>
```dart
Widget _buildRow(WordPair pair) {
Expand All @@ -506,7 +499,6 @@ lazily, on demand.
implements the basic Material Design visual layout.)
Replace the method body with the highlighted code:

<!-- skip -->
<?code-excerpt "lib/main.dart (build)" title region="RWS-build" replace="/(\n )(return.*| .*|\);)/$1[!$2!]/g" indent-by="2"?>
```dart
@override
Expand Down
2 changes: 1 addition & 1 deletion tool/extract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int _processFile(File file) {
}
lastComment = lastComment.substring(0, lastComment.length - 3);
} else if (lines[index].contains('<?code-') || lines[index].trim().isEmpty) {
// Carry on. In particular, don't reset lastComment.
lastComment = 'skip';
} else {
lastComment = null;
}
Expand Down

0 comments on commit 15ddba0

Please sign in to comment.