Skip to content

Commit 706e393

Browse files
committed
Dokka fixes
* Provide module with Kotlin 1.3 API because Kotlin 1.2 from Dokka can't read classes marked as "from the future" * Add runConfiguration dokkaStubs which is included only during dokka task with some classpath magic for Kotlin 1.3 * Add package.list for slf4j * Fix unresolved types/links in documentation * Suppress all internal/inherited API
1 parent b6eca2a commit 706e393

File tree

33 files changed

+178
-39
lines changed

33 files changed

+178
-39
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {
103103

104104
// --------------- Configure sub-projects that are part of the library ---------------
105105

106-
def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'binary-compatibility-validator']
106+
def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'stdlib-stubs', 'binary-compatibility-validator']
107107

108108
// Reconfigure source sets to avoid long "src/main/kotlin/fqn"
109109
configure(subprojects.findAll { !it.name.contains(sourceless) && it.name != "benchmarks" }) {

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

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ package kotlinx.coroutines
66

77
import kotlin.coroutines.*
88

9+
/**
10+
* Creates context for the new coroutine. It installs [Dispatchers.Default] when no other dispatcher nor
11+
* [ContinuationInterceptor] is specified, and adds optional support for debugging facilities (when turned on).
12+
*/
913
public expect fun CoroutineScope.newCoroutineContext(context: CoroutineContext): CoroutineContext
1014

1115
internal expect fun createDefaultDispatcher(): CoroutineDispatcher

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public abstract class CoroutineDispatcher :
103103
)
104104
public operator fun plus(other: CoroutineDispatcher) = other
105105

106-
// for nicer debugging
106+
/** @suppress for nicer debugging */
107107
override fun toString(): String = "$classSimpleName@$hexAddress"
108108
}
109109

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

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import kotlin.coroutines.*
5858
* ```
5959
*/
6060
public interface CoroutineScope {
61-
6261
/**
6362
* Context of this scope.
6463
*/

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlin.coroutines.*
1616
*
1717
* @suppress **This an internal API and should not be used from general code.**
1818
*/
19-
@InternalCoroutinesApi // todo: Remove references from other docs
19+
@InternalCoroutinesApi
2020
public interface Delay {
2121
/**
2222
* Delays coroutine for a given time without blocking a thread and resumes it after a specified time.
@@ -65,9 +65,7 @@ public interface Delay {
6565
*
6666
* Note, that delay can be used in [select] invocation with [onTimeout][SelectBuilder.onTimeout] clause.
6767
*
68-
* This function delegates to [Delay.scheduleResumeAfterDelay] if the context [CoroutineDispatcher]
69-
* implements [Delay] interface, otherwise it resumes using a built-in single-threaded scheduled executor service.
70-
*
68+
* Implementation note: how exactly time is tracked is an implementation detail of [CoroutineDispatcher] in the context.
7169
* @param timeMillis time in milliseconds.
7270
*/
7371
public suspend fun delay(timeMillis: Long) {

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

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
package kotlinx.coroutines
66

7+
/**
8+
* @suppress **This an internal API and should not be used from general code.**
9+
*/
710
@InternalCoroutinesApi
811
public expect class CompletionHandlerException(message: String, cause: Throwable) : RuntimeException
912

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55

66
package kotlinx.coroutines
77

8-
import kotlinx.coroutines.NonCancellable.isActive
98
import kotlinx.coroutines.selects.*
109
import kotlin.coroutines.*
1110

1211
/**
13-
* A non-cancelable job that is always [active][isActive]. It is designed for [withContext] function
12+
* A non-cancelable job that is always [active][Job.isActive]. It is designed for [withContext] function
1413
* to prevent cancellation of code blocks that need to be executed without cancellation.
1514
*
1615
* Use it like this:
@@ -26,7 +25,7 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
2625
* @suppress **This an internal API and should not be used from general code.**
2726
*/
2827
@InternalCoroutinesApi
29-
override val isActive: Boolean get() = true
28+
override val isActive: Boolean get() = true
3029

3130
/**
3231
* Always returns `false`.

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

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package kotlinx.coroutines
66

7+
/** @suppress */
78
public expect interface Runnable {
89
public fun run()
910
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import kotlin.coroutines.intrinsics.*
2020
* The sibling function that does not throw exception on timeout is [withTimeoutOrNull].
2121
* Note, that timeout action can be specified for [select] invocation with [onTimeout][SelectBuilder.onTimeout] clause.
2222
*
23-
* This function delegates to [Delay.invokeOnTimeout] if the context [CoroutineDispatcher]
24-
* implements [Delay] interface, otherwise it tracks time using a built-in single-threaded scheduled executor service.
23+
* Implementation note: how exactly time is tracked is an implementation detail of [CoroutineDispatcher] in the context.
2524
*
2625
* @param timeMillis timeout time in milliseconds.
2726
*/
@@ -42,8 +41,7 @@ public suspend fun <T> withTimeout(timeMillis: Long, block: suspend CoroutineSco
4241
* The sibling function that throws exception on timeout is [withTimeout].
4342
* Note, that timeout action can be specified for [select] invocation with [onTimeout][SelectBuilder.onTimeout] clause.
4443
*
45-
* This function delegates to [Delay.invokeOnTimeout] if the context [CoroutineDispatcher]
46-
* implements [Delay] interface, otherwise it tracks time using a built-in single-threaded scheduled executor service.
44+
* Implementation note: how exactly time is tracked is an implementation detail of [CoroutineDispatcher] in the context.
4745
*
4846
* @param timeMillis timeout time in milliseconds.
4947
*/

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public interface ChannelIterator<out E> {
342342
* while previously sent elements **are lost**.
343343
* Sender to this channel never suspends and [offer] always returns `true`.
344344
*
345-
* * When `capacity` is positive, but less than [UNLIMITED] -- it creates [ArrayChannel].
345+
* * When `capacity` is positive, but less than [UNLIMITED] -- it creates array-based channel with given capacity.
346346
* This channel has an array buffer of a fixed `capacity`.
347347
* Sender suspends only when buffer is fully and receiver suspends only when buffer is empty.
348348
*/

common/kotlinx-coroutines-core-common/src/internal/MainDispatcherFactory.kt

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package kotlinx.coroutines.internal
66

77
import kotlinx.coroutines.*
88

9+
/** @suppress */
910
@InternalCoroutinesApi // Emulating DI for Kotlin object's
1011
public interface MainDispatcherFactory {
1112
val loadPriority: Int // higher priority wins

common/kotlinx-coroutines-core-common/src/selects/Select.kt

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import kotlinx.coroutines.*
99
import kotlinx.coroutines.channels.*
1010
import kotlinx.coroutines.internal.*
1111
import kotlinx.coroutines.intrinsics.*
12+
import kotlinx.coroutines.sync.*
1213
import kotlin.coroutines.*
1314
import kotlin.coroutines.intrinsics.*
1415

@@ -150,12 +151,12 @@ public interface SelectInstance<in R> {
150151
*
151152
* | **Receiver** | **Suspending function** | **Select clause** | **Non-suspending version**
152153
* | ---------------- | --------------------------------------------- | ------------------------------------------------ | --------------------------
153-
* | [Job] | [join][Job.join] | [onJoin][SelectBuilder.onJoin] | [isCompleted][Job.isCompleted]
154-
* | [Deferred] | [await][Deferred.await] | [onAwait][SelectBuilder.onAwait] | [isCompleted][Job.isCompleted]
155-
* | [SendChannel] | [send][SendChannel.send] | [onSend][SelectBuilder.onSend] | [offer][SendChannel.offer]
156-
* | [ReceiveChannel] | [receive][ReceiveChannel.receive] | [onReceive][SelectBuilder.onReceive] | [poll][ReceiveChannel.poll]
157-
* | [ReceiveChannel] | [receiveOrNull][ReceiveChannel.receiveOrNull] | [onReceiveOrNull][SelectBuilder.onReceiveOrNull] | [poll][ReceiveChannel.poll]
158-
* | [Mutex] | [lock][Mutex.lock] | [onLock][SelectBuilder.onLock] | [tryLock][Mutex.tryLock]
154+
* | [Job] | [join][Job.join] | [onJoin][Job.onJoin] | [isCompleted][Job.isCompleted]
155+
* | [Deferred] | [await][Deferred.await] | [onAwait][Deferred.onAwait] | [isCompleted][Job.isCompleted]
156+
* | [SendChannel] | [send][SendChannel.send] | [onSend][SendChannel.onSend] | [offer][SendChannel.offer]
157+
* | [ReceiveChannel] | [receive][ReceiveChannel.receive] | [onReceive][ReceiveChannel.onReceive] | [poll][ReceiveChannel.poll]
158+
* | [ReceiveChannel] | [receiveOrNull][ReceiveChannel.receiveOrNull] | [onReceiveOrNull][ReceiveChannel.onReceiveOrNull]| [poll][ReceiveChannel.poll]
159+
* | [Mutex] | [lock][Mutex.lock] | [onLock][Mutex.onLock] | [tryLock][Mutex.tryLock]
159160
* | none | [delay] | [onTimeout][SelectBuilder.onTimeout] | none
160161
*
161162
* This suspending function is cancellable. If the [Job] of the current coroutine is cancelled or completed while this

common/kotlinx-coroutines-core-common/test/channels/BroadcastChannelFactoryTest.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
package kotlinx.coroutines.channels
66

7+
import kotlinx.coroutines.*
78
import kotlin.test.*
89

910

10-
class BroadcastChannelFactoryTest {
11+
class BroadcastChannelFactoryTest : TestBase() {
1112

1213
@Test
1314
fun testRendezvousChannelNotSupported() {

core/kotlinx-coroutines-core/src/Runnable.kt

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package kotlinx.coroutines
66

77
/**
88
* A runnable task for [CoroutineDispatcher.dispatch].
9+
* @suppress
910
*/
1011
public actual typealias Runnable = java.lang.Runnable
1112

core/kotlinx-coroutines-core/src/channels/Actor.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public interface ActorScope<E> : CoroutineScope, ReceiveChannel<E> {
101101
* @param context additional to [CoroutineScope.coroutineContext] context of the coroutine.
102102
* @param capacity capacity of the channel's buffer (no buffer by default).
103103
* @param start coroutine start option. The default value is [CoroutineStart.DEFAULT].
104-
* @param onCompletion optional completion handler for the actor coroutine (see [Job.invokeOnCompletion]).
104+
* @param onCompletion optional completion handler for the actor coroutine (see [Job.invokeOnCompletion])
105105
* @param block the coroutine code.
106106
*/
107107
@ObsoleteCoroutinesApi

core/stdlib-stubs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a workaround for Dokka to generate proper references for Kotlin 1.3 API.

core/stdlib-stubs/build.gradle

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
compileKotlin {
6+
kotlinOptions {
7+
freeCompilerArgs += "-Xallow-kotlin-package"
8+
}
9+
}

core/stdlib-stubs/src/Continuation.kt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
package kotlin.coroutines
5+
6+
// DOKKA STUB
7+
public interface Continuation<in T> {
8+
public val context: CoroutineContext
9+
public fun resumeWith(result: Result<T>)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
package kotlin.coroutines
5+
6+
// DOKKA STUB
7+
public interface ContinuationInterceptor : CoroutineContext.Element {
8+
companion object Key : CoroutineContext.Key<ContinuationInterceptor>
9+
public fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T>
10+
public fun releaseInterceptedContinuation(continuation: Continuation<*>): Continuation<*> {
11+
return continuation
12+
}
13+
public override operator fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E? = TODO()
14+
public override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext = TODO()
15+
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
package kotlin.coroutines
5+
6+
// DOKKA STUB
7+
public interface CoroutineContext {
8+
public operator fun <E : Element> get(key: Key<E>): E?
9+
public fun <R> fold(initial: R, operation: (R, Element) -> R): R
10+
public operator fun plus(context: CoroutineContext): CoroutineContext = TODO()
11+
public fun minusKey(key: Key<*>): CoroutineContext
12+
public interface Key<E : Element>
13+
public interface Element : CoroutineContext {
14+
public val key: Key<*>
15+
16+
public override operator fun <E : Element> get(key: Key<E>): E? =
17+
@Suppress("UNCHECKED_CAST")
18+
if (this.key == key) this as E else null
19+
20+
public override fun <R> fold(initial: R, operation: (R, Element) -> R): R =
21+
operation(initial, this)
22+
23+
public override fun minusKey(key: Key<*>): CoroutineContext =
24+
if (this.key == key) EmptyCoroutineContext else this
25+
}
26+
}
27+
28+
public object EmptyCoroutineContext : CoroutineContext {
29+
private const val serialVersionUID: Long = 0
30+
private fun readResolve(): Any = EmptyCoroutineContext
31+
32+
public override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E? = null
33+
public override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R = initial
34+
public override fun plus(context: CoroutineContext): CoroutineContext = context
35+
public override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext = this
36+
public override fun hashCode(): Int = 0
37+
public override fun toString(): String = "EmptyCoroutineContext"
38+
}

core/stdlib-stubs/src/Result.kt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlin
6+
7+
interface Result<out T> {
8+
public val value: T
9+
public val isSuccess: Boolean
10+
public val isFailure: Boolean
11+
public fun exceptionOrNull(): Throwable?
12+
public fun getOrNull(): T?
13+
public fun getOrThrow(): T
14+
}

docs/channels.md

+1
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ delay between elements.
627627
<!--- INDEX kotlinx.coroutines -->
628628
[CoroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html
629629
[runBlocking]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html
630+
[kotlin.coroutines.CoroutineContext.cancelChildren]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/kotlin.coroutines.-coroutine-context/cancel-children.html
630631
[Dispatchers.Default]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html
631632
<!--- INDEX kotlinx.coroutines.channels -->
632633
[Channel]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-channel/index.html

gradle/dokka.gradle

+17-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def makeLinkMapping(dokka, projectDir) {
1616
}
1717
}
1818

19+
configurations {
20+
dokkaStubs.extendsFrom compileOnly
21+
}
22+
1923
if (platform == "jvm") {
2024
apply plugin: 'org.jetbrains.dokka'
2125

@@ -24,14 +28,24 @@ if (platform == "jvm") {
2428
includes = ['README.md']
2529
}
2630

31+
dependencies {
32+
dokkaStubs project(":stdlib-stubs")
33+
}
34+
2735
dokka {
36+
kotlinTasks { [] }
2837
outputFormat = 'kotlin-website'
38+
afterEvaluate {
39+
dependsOn(project.configurations.dokkaStubs)
40+
dependsOn(project.configurations.compileClasspath)
41+
classpath = project.configurations.dokkaStubs.files + project.configurations.compileClasspath.files + project.sourceSets.main.output.files
42+
}
2943
}
3044

3145
if (project.name == coroutines_core) {
3246
// Custom configuration for MPP modules
3347
dependencies {
34-
compileOnly project(":js-stub") // so that JS library reference can resolve properly
48+
dokkaStubs project(":js-stub") // so that JS library reference can resolve properly
3549
}
3650

3751
dokka {
@@ -63,8 +77,9 @@ if (platform == "jvm") {
6377
dependsOn(tasks.getByPath(":$project.name:classes"))
6478
dependsOn(tasks.getByPath(":$project.name-js:classes"))
6579
dependsOn(tasks.getByPath(":$project.name-common:classes"))
80+
dependsOn(project.configurations.dokkaStubs)
6681
dependsOn(project.configurations.compileClasspath)
67-
classpath = project.configurations.compileClasspath.files + project.sourceSets.main.output.files
82+
classpath = project.configurations.dokkaStubs.files + project.configurations.compileClasspath.files + project.sourceSets.main.output.files
6883
}
6984
}
7085
}

integration/kotlinx-coroutines-play-services/build.gradle

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ dependencies {
3838
tasks.withType(dokka.getClass()) {
3939
externalDocumentationLink {
4040
url = new URL("https://developers.google.com/android/reference/")
41-
/*
42-
* This is workaround for missing package list in Google API
43-
*/
44-
packageListUrl = rootDir.toPath().resolve("integration/kotlinx-coroutines-play-services/resources/package.list").toUri().toURL()
41+
// This is workaround for missing package list in Google API
42+
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
43+
}
44+
45+
afterEvaluate {
46+
classpath += project.configurations.aar.files
4547
}
4648
}
4749

integration/kotlinx-coroutines-slf4j/build.gradle

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ dependencies {
55
testRuntime 'ch.qos.logback:logback-core:1.2.3'
66
}
77

8-
//tasks.withType(dokka.getClass()) {
9-
// externalDocumentationLink {
10-
// url = new URL("https://www.slf4j.org/apidocs/")
11-
// }
12-
//}
8+
tasks.withType(dokka.getClass()) {
9+
externalDocumentationLink {
10+
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
11+
url = new URL("https://www.slf4j.org/apidocs/")
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
org.apache.commons.logging
2+
org.apache.commons.logging.impl
3+
org.apache.log4j
4+
org.apache.log4j.helpers
5+
org.apache.log4j.spi
6+
org.apache.log4j.xml
7+
org.slf4j
8+
org.slf4j.agent
9+
org.slf4j.bridge
10+
org.slf4j.cal10n
11+
org.slf4j.event
12+
org.slf4j.ext
13+
org.slf4j.helpers
14+
org.slf4j.instrumentation
15+
org.slf4j.jul
16+
org.slf4j.log4j12
17+
org.slf4j.nop
18+
org.slf4j.osgi.logservice.impl
19+
org.slf4j.profiler
20+
org.slf4j.simple
21+
org.slf4j.spi

0 commit comments

Comments
 (0)