Skip to content

Commit 96b89a6

Browse files
authored
Continue docregion/excerpt cleanup (#5703)
- Migrates away from last unnamed regions - Close some unclosed regions - Some other misc cleanup Contributes to #5593
1 parent db00a90 commit 96b89a6

File tree

11 files changed

+33
-31
lines changed

11 files changed

+33
-31
lines changed

examples/async_await/bin/futures_intro.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ void main() {
1919
fetchUserOrder();
2020
print('Fetching user order...');
2121
}
22-
// #enddocregion no-error
22+
// #enddocregion no-error, error

examples/extension_methods/lib/string_extensions/usage_simple_extension.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ void main() {
1111
print(double.parse('42'));
1212

1313
// WITH extension methods.
14-
// #docregion import-and-use
14+
// #docregion import-and-use
1515
print('42'.padLeft(5)); // Use a String method.
16-
// #docregion basic
16+
// #docregion basic
1717
print('42'.parseInt()); // Use an extension method.
18-
// #enddocregion basic, import-and-use
18+
// #enddocregion basic, import-and-use
1919
print('42'.parseDouble());
2020

2121
// var vs. dynamic.

examples/misc/lib/language_tour/classes/employee.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Employee extends Person {
2222
Employee.fromJson(super.data) : super.fromJson() {
2323
print('in Employee');
2424
}
25-
// #docregion method-then-constructor
25+
// #docregion method-then-constructor
2626
}
2727
// #enddocregion method-then-constructor
2828

examples/misc/lib/language_tour/classes/extends.dart

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ class SmartTelevision extends Television {
2626
void _upgradeApps() {}
2727
// #docregion smart-tv
2828
}
29+
// #enddocregion smart-tv

examples/misc/lib/library_tour/core/hash_code.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// ignore_for_file: unrelated_type_equality_checks
2-
// #docregion
32
class Person {
43
final String firstName, lastName;
54

examples/misc/lib/library_tour/core/iterator.dart

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ import 'dart:collection';
22

33
final Iterator<Process> _it = [Process(), Process(), Process()].iterator;
44

5-
// #docregion
5+
// #docregion structure
66
class Process {
77
// Represents a process...
8-
// #enddocregion
8+
// #enddocregion structure
99
static int _nextId = 0;
1010
final int id = _nextId++;
11-
// #docregion
11+
// #docregion structure
1212
}
1313

1414
class ProcessIterator implements Iterator<Process> {
1515
@override
1616
Process get current => /*...*/
17-
// #enddocregion
17+
// #enddocregion structure
1818
_it.current;
19-
// #docregion
19+
// #docregion structure
2020
@override
2121
bool moveNext() => /*...*/
22-
// #enddocregion
22+
// #enddocregion structure
2323
_it.moveNext();
24-
// #docregion
24+
// #docregion structure
2525
}
2626

2727
// A mythical class that lets you iterate through all
@@ -35,8 +35,9 @@ void main() {
3535
// Iterable objects can be used with for-in.
3636
for (final process in Processes()) {
3737
// Do something with the process.
38-
// #enddocregion
38+
// #enddocregion structure
3939
print(process.id);
40-
// #docregion
40+
// #docregion structure
4141
}
4242
}
43+
// #enddocregion structure

examples/misc/lib/library_tour/io/http_server.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import 'dart:io';
22

33
int stopAfter = 10;
4-
// #docregion
4+
// #docregion process-requests
55
Future<void> main() async {
66
final requests = await HttpServer.bind('localhost', 8888);
7-
// #enddocregion
7+
// #enddocregion process-requests
88
// ignore: no_leading_underscores_for_local_identifiers
99
final _requests = requests.take(stopAfter);
10-
// #docregion
10+
// #docregion process-requests
1111
await for (final request in _requests) {
1212
processRequest(request);
1313
}
@@ -28,3 +28,4 @@ void processRequest(HttpRequest request) {
2828
}
2929
response.close();
3030
}
31+
// #enddocregion process-requests

examples/non_promotion/lib/non_promotion.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ void miscDeclAnalyzedButNotTested() {
8484

8585
{
8686
void f(int? i, int? j) {
87-
// #docregion catch-null-check
88-
// #enddocregion catch-null-check
8987
if (i == null) return;
88+
// #docregion catch-null-check
9089
try {
90+
// #enddocregion catch-null-check
9191
i = j; // (1)
9292
// ... Additional code ...
9393
if (i == null) return; // (2)
@@ -106,10 +106,10 @@ void miscDeclAnalyzedButNotTested() {
106106

107107
{
108108
void f(int? i, int? j) {
109-
// #docregion catch-bang
110-
// #enddocregion catch-bang
111109
if (i == null) return;
110+
// #docregion catch-bang
112111
try {
112+
// #enddocregion catch-bang
113113
i = j; // (1)
114114
// ... Additional code ...
115115
if (i == null) return; // (2)

src/content/libraries/dart-core.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ If you create a class that can provide Iterators for use in for-in loops,
953953
extend (if possible) or implement Iterable.
954954
Implement Iterator to define the actual iteration ability.
955955

956-
<?code-excerpt "misc/lib/library_tour/core/iterator.dart"?>
956+
<?code-excerpt "misc/lib/library_tour/core/iterator.dart (structure)"?>
957957
```dart
958958
class Process {
959959
// Represents a process...
@@ -990,13 +990,11 @@ catch. Errors are conditions that you don't expect or plan for.
990990
A couple of the most common errors are:
991991

992992
[NoSuchMethodError][]
993-
994-
: Thrown when a receiving object (which might be null) does not
995-
implement a method.
993+
: Thrown when a receiving object (which might be `null`) does not
994+
implement a method.
996995

997996
[ArgumentError][]
998-
999-
: Can be thrown by a method that encounters an unexpected argument.
997+
: Can be thrown by a method that encounters an unexpected argument.
1000998

1001999
Throwing an application-specific exception is a common way to indicate
10021000
that an error has occurred. You can define a custom exception by

src/content/libraries/dart-io.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ This server listens on port 8888 and address 127.0.0.1 (localhost),
217217
responding to requests for the path `/dart`. For any other path,
218218
the response is status code 404 (page not found).
219219

220-
<?code-excerpt "misc/lib/library_tour/io/http_server.dart" replace="/Future<\w+\W/void/g; /\b_//g"?>
220+
<?code-excerpt "misc/lib/library_tour/io/http_server.dart (process-requests)" replace="/Future<\w+\W/void/g; /\b_//g"?>
221221
```dart
222222
void main() async {
223223
final requests = await HttpServer.bind('localhost', 8888);

src/content/tools/non-promotion-reasons.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,8 @@ The safest solution is to add a null check inside the `catch` block:
871871

872872
<?code-excerpt "non_promotion/lib/non_promotion.dart (catch-null-check)" replace="/if.*/[!$&!]/g;/(} else {| \/\/ H.*)/[!$&!]/g;/ }/ [!}!]/g"?>
873873
```dart tag=good
874-
// ···
874+
try {
875+
// ···
875876
} catch (e) {
876877
[!if (i != null) {!]
877878
print(i.isEven); // (3) OK due to the null check in the line above.
@@ -886,7 +887,8 @@ just use the `!` operator:
886887

887888
<?code-excerpt "non_promotion/lib/non_promotion.dart (catch-bang)" replace="/i!/i[!!!]/g"?>
888889
```dart
889-
// ···
890+
try {
891+
// ···
890892
} catch (e) {
891893
print(i[!!!].isEven); // (3) OK because of the `!`.
892894
}

0 commit comments

Comments
 (0)