Skip to content

Commit 84a6ef9

Browse files
Use consistent indentation in our documentation (#4122)
Found using `git grep -P '\* ?[a-zA-Z]'` --------- Co-authored-by: Dmitry Khalanskiy <[email protected]>
1 parent 4c24659 commit 84a6ef9

File tree

20 files changed

+144
-144
lines changed

20 files changed

+144
-144
lines changed

integration/kotlinx-coroutines-slf4j/src/MDCContext.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public typealias MDCContextMap = Map<String, String>?
3333
*
3434
* ```
3535
* launch(MDCContext()) {
36-
* MDC.put("key", "value") // This update will be lost
37-
* delay(100)
38-
* println(MDC.get("key")) // This will print null
36+
* MDC.put("key", "value") // This update will be lost
37+
* delay(100)
38+
* println(MDC.get("key")) // This will print null
3939
* }
4040
* ```
4141
*

kotlinx-coroutines-core/common/src/CancellableContinuation.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ internal fun <T> CancellableContinuation<T>.invokeOnCancellation(handler: Cancel
274274
*
275275
* ```
276276
* suspendCancellableCoroutine { continuation ->
277-
* val resource = openResource() // Opens some resource
278-
* continuation.invokeOnCancellation {
279-
* resource.close() // Ensures the resource is closed on cancellation
280-
* }
281-
* // ...
277+
* val resource = openResource() // Opens some resource
278+
* continuation.invokeOnCancellation {
279+
* resource.close() // Ensures the resource is closed on cancellation
280+
* }
281+
* // ...
282282
* }
283283
* ```
284284
*

kotlinx-coroutines-core/common/src/CancellableContinuationImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ internal open class CancellableContinuationImpl<in T>(
366366
*
367367
* ```
368368
* invokeOnCancellation { cause ->
369-
* segment.onCancellation(index, cause)
369+
* segment.onCancellation(index, cause)
370370
* }
371371
* ```
372372
*/

kotlinx-coroutines-core/common/src/Debug.common.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ internal expect fun assert(value: () -> Boolean)
1313
* ```
1414
* class BadResponseCodeException(val responseCode: Int) : Exception(), CopyableThrowable<BadResponseCodeException> {
1515
*
16-
* override fun createCopy(): BadResponseCodeException {
17-
* val result = BadResponseCodeException(responseCode)
18-
* result.initCause(this)
19-
* return result
20-
* }
16+
* override fun createCopy(): BadResponseCodeException {
17+
* val result = BadResponseCodeException(responseCode)
18+
* result.initCause(this)
19+
* return result
20+
* }
2121
* ```
2222
*
2323
* Copy mechanism is used only on JVM, but it might be convenient to implement it in common exceptions,

kotlinx-coroutines-core/common/src/Deferred.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public interface Deferred<out T> : Job {
5151
* The following idiom may be helpful to avoid this:
5252
* ```
5353
* try {
54-
* deferred.await()
54+
* deferred.await()
5555
* } catch (e: CancellationException) {
56-
* currentCoroutineContext().ensureActive() // throws if the current coroutine was cancelled
57-
* processException(e) // if this line executes, the exception is the result of `await` itself
56+
* currentCoroutineContext().ensureActive() // throws if the current coroutine was cancelled
57+
* processException(e) // if this line executes, the exception is the result of `await` itself
5858
* }
5959
* ```
6060
*

kotlinx-coroutines-core/common/src/Dispatchers.common.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public expect object Dispatchers {
5252
* For example, the following code:
5353
* ```
5454
* withContext(Dispatchers.Unconfined) {
55-
* println(1)
56-
* launch(Dispatchers.Unconfined) { // Nested unconfined
57-
* println(2)
58-
* }
59-
* println(3)
55+
* println(1)
56+
* launch(Dispatchers.Unconfined) { // Nested unconfined
57+
* println(2)
58+
* }
59+
* println(3)
6060
* }
6161
* println("Done")
6262
* ```

kotlinx-coroutines-core/common/src/MainCoroutineDispatcher.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ public abstract class MainCoroutineDispatcher : CoroutineDispatcher() {
2121
* Example of usage:
2222
* ```
2323
* suspend fun updateUiElement(val text: String) {
24-
* /*
25-
* * If it is known that updateUiElement can be invoked both from the Main thread and from other threads,
26-
* * `immediate` dispatcher is used as a performance optimization to avoid unnecessary dispatch.
27-
* *
28-
* * In that case, when `updateUiElement` is invoked from the Main thread, `uiElement.text` will be
29-
* * invoked immediately without any dispatching, otherwise, the `Dispatchers.Main` dispatch cycle will be triggered.
30-
* */
31-
* withContext(Dispatchers.Main.immediate) {
32-
* uiElement.text = text
33-
* }
34-
* // Do context-independent logic such as logging
24+
* /*
25+
* * If it is known that updateUiElement can be invoked both from the Main thread and from other threads,
26+
* * `immediate` dispatcher is used as a performance optimization to avoid unnecessary dispatch.
27+
* *
28+
* * In that case, when `updateUiElement` is invoked from the Main thread, `uiElement.text` will be
29+
* * invoked immediately without any dispatching, otherwise, the `Dispatchers.Main` dispatch cycle will be triggered.
30+
* */
31+
* withContext(Dispatchers.Main.immediate) {
32+
* uiElement.text = text
33+
* }
34+
* // Do context-independent logic such as logging
3535
* }
3636
* ```
3737
*

kotlinx-coroutines-core/common/src/channels/Channel.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ public interface SendChannel<in E> {
116116
* ```
117117
* val events = Channel<Event>(UNLIMITED)
118118
* callbackBasedApi.registerCallback { event ->
119-
* events.trySend(event)
120-
* .onClosed { /* channel is already closed, but the callback hasn't stopped yet */ }
119+
* events.trySend(event)
120+
* .onClosed { /* channel is already closed, but the callback hasn't stopped yet */ }
121121
* }
122122
*
123123
* val uiUpdater = uiScope.launch(Dispatchers.Main) {
124-
* events.consume { /* handle events */ }
124+
* events.consume { /* handle events */ }
125125
* }
126126
* // Stop the callback after the channel is closed or cancelled
127127
* events.invokeOnClose { callbackBasedApi.stop() }
@@ -145,7 +145,7 @@ public interface SendChannel<in E> {
145145
* It has proven itself as the most error-prone method in Channel API:
146146
*
147147
* - `Boolean` return type creates the false sense of security, implying that `false`
148-
* is returned instead of throwing an exception.
148+
* is returned instead of throwing an exception.
149149
* - It was used mostly from non-suspending APIs where CancellationException triggered
150150
* internal failures in the application (the most common source of bugs).
151151
* - Due to signature and explicit `if (ch.offer(...))` checks it was easy to
@@ -323,7 +323,7 @@ public interface ReceiveChannel<out E> {
323323
* It has proven itself as error-prone method in Channel API:
324324
*
325325
* - Nullable return type creates the false sense of security, implying that `null`
326-
* is returned instead of throwing an exception.
326+
* is returned instead of throwing an exception.
327327
* - It was used mostly from non-suspending APIs where CancellationException triggered
328328
* internal failures in the application (the most common source of bugs).
329329
* - Its name was not aligned with the rest of the API and tried to mimic Java's queue instead.

kotlinx-coroutines-core/common/src/flow/Flow.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ import kotlin.coroutines.*
102102
*
103103
* ```
104104
* val myFlow = flow {
105-
* // GlobalScope.launch { // is prohibited
106-
* // launch(Dispatchers.IO) { // is prohibited
107-
* // withContext(CoroutineName("myFlow")) { // is prohibited
108-
* emit(1) // OK
109-
* coroutineScope {
110-
* emit(2) // OK -- still the same coroutine
111-
* }
105+
* // GlobalScope.launch { // is prohibited
106+
* // launch(Dispatchers.IO) { // is prohibited
107+
* // withContext(CoroutineName("myFlow")) { // is prohibited
108+
* emit(1) // OK
109+
* coroutineScope {
110+
* emit(2) // OK -- still the same coroutine
111+
* }
112112
* }
113113
* ```
114114
*
@@ -119,11 +119,11 @@ import kotlin.coroutines.*
119119
*
120120
* If you are looking for performance and are sure that no concurrent emits and context jumps will happen,
121121
* the [flow] builder can be used alongside a [coroutineScope] or [supervisorScope] instead:
122-
* - Scoped primitive should be used to provide a [CoroutineScope].
123-
* - Changing the context of emission is prohibited, no matter whether it is `withContext(ctx)` or
124-
* a builder argument (e.g. `launch(ctx)`).
125-
* - Collecting another flow from a separate context is allowed, but it has the same effect as
126-
* applying the [flowOn] operator to that flow, which is more efficient.
122+
* - Scoped primitive should be used to provide a [CoroutineScope].
123+
* - Changing the context of emission is prohibited, no matter whether it is `withContext(ctx)` or
124+
* a builder argument (e.g. `launch(ctx)`).
125+
* - Collecting another flow from a separate context is allowed, but it has the same effect as
126+
* applying the [flowOn] operator to that flow, which is more efficient.
127127
*
128128
* ### Exception transparency
129129
*

kotlinx-coroutines-core/common/src/flow/SharedFlow.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ import kotlin.jvm.*
8686
* It has the following important differences:
8787
*
8888
* - `SharedFlow` is simpler, because it does not have to implement all the [Channel] APIs, which allows
89-
* for faster and simpler implementation.
89+
* for faster and simpler implementation.
9090
* - `SharedFlow` supports configurable replay and buffer overflow strategy.
9191
* - `SharedFlow` has a clear separation into a read-only `SharedFlow` interface and a [MutableSharedFlow].
9292
* - `SharedFlow` cannot be closed like `BroadcastChannel` and can never represent a failure.
93-
* All errors and completion signals should be explicitly _materialized_ if needed.
93+
* All errors and completion signals should be explicitly _materialized_ if needed.
9494
*
9595
* To migrate [BroadcastChannel] usage to [SharedFlow], start by replacing usages of the `BroadcastChannel(capacity)`
9696
* constructor with `MutableSharedFlow(0, extraBufferCapacity=capacity)` (broadcast channel does not replay
@@ -138,7 +138,7 @@ public interface SharedFlow<out T> : Flow<T> {
138138
* ```
139139
* val flow = MutableSharedFlow<Int>()
140140
* launch(start = CoroutineStart.UNDISPATCHED) {
141-
* flow.collect { println(1) }
141+
* flow.collect { println(1) }
142142
* }
143143
* flow.emit(1)
144144
* ```

0 commit comments

Comments
 (0)