Skip to content

Commit 87d0885

Browse files
invalidnameChris Adamson
andauthored
AsyncStream: Explicit code-block fence around doc code snippet. (#41407)
* Explicit code-block fence around doc code snippet. * Doc snippet: remove unnecessary indentation. Co-authored-by: Chris Adamson <[email protected]>
1 parent 4678496 commit 87d0885

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

stdlib/public/Concurrency/AsyncStream.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,23 @@ import Swift
6868
/// calls `stopMonitoring()` on the monitor.
6969
/// 4. Calls `startMonitoring` on the `QuakeMonitor`.
7070
///
71-
/// extension QuakeMonitor {
71+
/// ```
72+
/// extension QuakeMonitor {
7273
///
73-
/// static var quakes: AsyncStream<Quake> {
74-
/// AsyncStream { continuation in
75-
/// let monitor = QuakeMonitor()
76-
/// monitor.quakeHandler = { quake in
77-
/// continuation.yield(quake)
78-
/// }
79-
/// continuation.onTermination = { @Sendable _ in
80-
/// monitor.stopMonitoring()
81-
/// }
82-
/// monitor.startMonitoring()
74+
/// static var quakes: AsyncStream<Quake> {
75+
/// AsyncStream { continuation in
76+
/// let monitor = QuakeMonitor()
77+
/// monitor.quakeHandler = { quake in
78+
/// continuation.yield(quake)
8379
/// }
80+
/// continuation.onTermination = { @Sendable _ in
81+
/// monitor.stopMonitoring()
82+
/// }
83+
/// monitor.startMonitoring()
8484
/// }
8585
/// }
86+
/// }
87+
/// ```
8688
///
8789
/// Because the stream is an `AsyncSequence`, the call point can use the
8890
/// `for`-`await`-`in` syntax to process each `Quake` instance as the stream
@@ -265,7 +267,7 @@ public struct AsyncStream<Element> {
265267
/// The following example shows an `AsyncStream` created with this
266268
/// initializer that produces 100 random numbers on a one-second interval,
267269
/// calling `yield(_:)` to deliver each element to the awaiting call point.
268-
/// When the `for` loop exits and the stream finishes by calling the
270+
/// When the `for` loop exits, the stream finishes by calling the
269271
/// continuation's `finish()` method.
270272
///
271273
/// let stream = AsyncStream<Int>(Int.self,

stdlib/public/Concurrency/AsyncThrowingStream.swift

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,26 @@ import Swift
8080
/// calls `stopMonitoring()` on the monitor.
8181
/// 5. Calls `startMonitoring` on the `QuakeMonitor`.
8282
///
83-
/// extension QuakeMonitor {
83+
/// ```
84+
/// extension QuakeMonitor {
8485
///
85-
/// static var throwingQuakes: AsyncThrowingStream<Quake, Error> {
86-
/// AsyncThrowingStream { continuation in
87-
/// let monitor = QuakeMonitor()
88-
/// monitor.quakeHandler = { quake in
89-
/// continuation.yield(quake)
90-
/// }
91-
/// monitor.errorHandler = { error in
92-
/// continuation.finish(throwing: error)
93-
/// }
94-
/// continuation.onTermination = { @Sendable _ in
95-
/// monitor.stopMonitoring()
96-
/// }
97-
/// monitor.startMonitoring()
86+
/// static var throwingQuakes: AsyncThrowingStream<Quake, Error> {
87+
/// AsyncThrowingStream { continuation in
88+
/// let monitor = QuakeMonitor()
89+
/// monitor.quakeHandler = { quake in
90+
/// continuation.yield(quake)
9891
/// }
92+
/// monitor.errorHandler = { error in
93+
/// continuation.finish(throwing: error)
94+
/// }
95+
/// continuation.onTermination = { @Sendable _ in
96+
/// monitor.stopMonitoring()
97+
/// }
98+
/// monitor.startMonitoring()
9999
/// }
100100
/// }
101+
/// }
102+
/// ```
101103
///
102104
///
103105
/// Because the stream is an `AsyncSequence`, the call point uses the
@@ -289,7 +291,7 @@ public struct AsyncThrowingStream<Element, Failure: Error> {
289291
/// The following example shows an `AsyncStream` created with this
290292
/// initializer that produces 100 random numbers on a one-second interval,
291293
/// calling `yield(_:)` to deliver each element to the awaiting call point.
292-
/// When the `for` loop exits and the stream finishes by calling the
294+
/// When the `for` loop exits, the stream finishes by calling the
293295
/// continuation's `finish()` method. If the random number is divisble by 5
294296
/// with no remainder, the stream throws a `MyRandomNumberError`.
295297
///

0 commit comments

Comments
 (0)