Skip to content

Commit fd0428e

Browse files
committed
Merge remote-tracking branch 'origin/master' into develop
2 parents b4f00c0 + 071f536 commit fd0428e

File tree

2 files changed

+113
-33
lines changed

2 files changed

+113
-33
lines changed

README.md

+96-24
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,36 @@ suspend fun main() = coroutineScope {
2222
## Modules
2323

2424
* [core](kotlinx-coroutines-core/README.md) — common coroutines across all platforms:
25-
* `launch` and `async` coroutine builders;
26-
* `Job` and `Deferred` light-weight future with cancellation support;
27-
* `MainScope` for Android and UI applications.
28-
* `Dispatchers` object with `Main` dispatcher for Android/Swing/JavaFx, and `Default` dispatcher for background coroutines;
29-
* `delay` and `yield` top-level suspending functions;
30-
* `Channel` and `Mutex` communication and synchronization primitives;
31-
* `coroutineScope` and `supervisorScope` scope builders;
32-
* `SupervisorJob` and `CoroutineExceptionHandler` for supervision of coroutines hierarchies;
33-
* `select` expression support and more.
25+
* [launch] and [async] coroutine builders returning [Job] and [Deferred] light-weight futures with cancellation support;
26+
* [Dispatchers] object with [Main][Dispatchers.Main] dispatcher for Android/Swing/JavaFx, and [Default][Dispatchers.Default] dispatcher for background coroutines;
27+
* [delay] and [yield] top-level suspending functions;
28+
* [Flow] — cold asynchronous stream with [flow][_flow] builder and comprehensive operator set ([filter], [map], etc);
29+
* [Channel], [Mutex], and [Semaphore] communication and synchronization primitives;
30+
* [coroutineScope], [supervisorScope], [withContext], and [withTimeout] scope builders;
31+
* [MainScope()] for Android and UI applications;
32+
* [SupervisorJob()] and [CoroutineExceptionHandler] for supervision of coroutines hierarchies;
33+
* [select] expression support and more.
3434
* [core/jvm](kotlinx-coroutines-core/jvm/) — additional core features available on Kotlin/JVM:
35-
* `Dispatchers.IO` dispatcher for blocking coroutines;
36-
* `Executor.asCoroutineDispatcher()` extension, custom thread pools, and more.
35+
* [Dispatchers.IO] dispatcher for blocking coroutines;
36+
* [Executor.asCoroutineDispatcher] extension, custom thread pools, and more.
3737
* [core/js](kotlinx-coroutines-core/js/) — additional core features available on Kotlin/JS:
38-
* Integration with `Promise`;
39-
* Integration with `Window`.
40-
* [test](kotlinx-coroutines-test/README.md) — test utilities for coroutines
41-
* `Dispatchers.setMain` to override `Dispatchers.Main` in tests.
42-
* `TestCoroutineScope` to test suspending functions and coroutines.
43-
* [debug](kotlinx-coroutines-debug/README.md) — debug utilities for coroutines.
44-
* `DebugProbes` API to probe, keep track of, print and dump active coroutines.
45-
* `CoroutinesTimeout` test rule to automatically dump coroutines on test timeout.
38+
* Integration with `Promise` via [Promise.await] and [promise] builder;
39+
* Integration with `Window` via [Window.asCoroutineDispatcher], etc.
40+
* [test](kotlinx-coroutines-test/README.md) — test utilities for coroutines:
41+
* [Dispatchers.setMain] to override [Dispatchers.Main] in tests;
42+
* [TestCoroutineScope] to test suspending functions and coroutines.
43+
* [debug](kotlinx-coroutines-debug/README.md) — debug utilities for coroutines:
44+
* [DebugProbes] API to probe, keep track of, print and dump active coroutines;
45+
* [CoroutinesTimeout] test rule to automatically dump coroutines on test timeout.
4646
* [reactive](reactive/README.md) — modules that provide builders and iteration support for various reactive streams libraries:
47-
* Reactive Streams, RxJava 2.x, and Project Reactor.
47+
* Reactive Streams ([Publisher.collect], [Publisher.awaitSingle], [publish], etc),
48+
RxJava 2.x ([rxFlowable], [rxSingle], etc), and
49+
Project Reactor ([flux], [mono], etc).
4850
* [ui](ui/README.md) — modules that provide coroutine dispatchers for various single-threaded UI libraries:
4951
* Android, JavaFX, and Swing.
50-
* [integration](integration/README.md) — modules that provide integration with various asynchronous callback- and future-based libraries.
51-
* JDK8 `CompletableFuture`, Guava `ListenableFuture`, and Google Play Services `Task`;
52-
* SLF4J MDC integration via `MDCContext`.
52+
* [integration](integration/README.md) — modules that provide integration with various asynchronous callback- and future-based libraries:
53+
* JDK8 [CompletionStage.await], Guava [ListenableFuture.await], and Google Play Services [Task.await];
54+
* SLF4J MDC integration via [MDCContext].
5355

5456
## Documentation
5557

@@ -156,7 +158,7 @@ module as dependency when using `kotlinx.coroutines` on Android:
156158
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
157159
```
158160

159-
This gives you access to Android [Dispatchers.Main](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-android/kotlinx.coroutines.android/kotlinx.coroutines.-dispatchers/index.html)
161+
This gives you access to Android [Dispatchers.Main]
160162
coroutine dispatcher and also makes sure that in case of crashed coroutine with unhandled exception this
161163
exception is logged before crashing Android application, similarly to the way uncaught exceptions in
162164
threads are handled by Android runtime.
@@ -217,3 +219,73 @@ The `develop` branch is pushed to `master` during release.
217219
* Full release procedure checklist is [here](RELEASE.md).
218220
* Steps for contributing new integration modules are explained [here](integration/README.md#Contributing).
219221

222+
<!--- MODULE kotlinx-coroutines-core -->
223+
<!--- INDEX kotlinx.coroutines -->
224+
[launch]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html
225+
[async]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html
226+
[Job]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/index.html
227+
[Deferred]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/index.html
228+
[Dispatchers]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/index.html
229+
[Dispatchers.Main]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-main.html
230+
[Dispatchers.Default]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html
231+
[delay]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/delay.html
232+
[yield]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/yield.html
233+
[coroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html
234+
[supervisorScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/supervisor-scope.html
235+
[withContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/with-context.html
236+
[withTimeout]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/with-timeout.html
237+
[MainScope()]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-main-scope.html
238+
[SupervisorJob()]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-supervisor-job.html
239+
[CoroutineExceptionHandler]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-exception-handler/index.html
240+
[Dispatchers.IO]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html
241+
[Executor.asCoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/java.util.concurrent.-executor/as-coroutine-dispatcher.html
242+
[Promise.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/kotlin.js.-promise/await.html
243+
[promise]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/promise.html
244+
[Window.asCoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/org.w3c.dom.-window/as-coroutine-dispatcher.html
245+
<!--- INDEX kotlinx.coroutines.flow -->
246+
[Flow]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html
247+
[_flow]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/flow.html
248+
[filter]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/filter.html
249+
[map]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/map.html
250+
<!--- INDEX kotlinx.coroutines.channels -->
251+
[Channel]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-channel/index.html
252+
<!--- INDEX kotlinx.coroutines.selects -->
253+
[select]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.selects/select.html
254+
<!--- INDEX kotlinx.coroutines.sync -->
255+
[Mutex]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/index.html
256+
[Semaphore]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-semaphore/index.html
257+
<!--- MODULE kotlinx-coroutines-test -->
258+
<!--- INDEX kotlinx.coroutines.test -->
259+
[Dispatchers.setMain]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/kotlinx.coroutines.-dispatchers/set-main.html
260+
[TestCoroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scope/index.html
261+
<!--- MODULE kotlinx-coroutines-debug -->
262+
<!--- INDEX kotlinx.coroutines.debug -->
263+
[DebugProbes]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-debug/kotlinx.coroutines.debug/-debug-probes/index.html
264+
<!--- INDEX kotlinx.coroutines.debug.junit4 -->
265+
[CoroutinesTimeout]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-debug/kotlinx.coroutines.debug.junit4/-coroutines-timeout/index.html
266+
<!--- MODULE kotlinx-coroutines-slf4j -->
267+
<!--- INDEX kotlinx.coroutines.slf4j -->
268+
[MDCContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-slf4j/kotlinx.coroutines.slf4j/-m-d-c-context/index.html
269+
<!--- MODULE kotlinx-coroutines-jdk8 -->
270+
<!--- INDEX kotlinx.coroutines.future -->
271+
[CompletionStage.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-jdk8/kotlinx.coroutines.future/java.util.concurrent.-completion-stage/await.html
272+
<!--- MODULE kotlinx-coroutines-guava -->
273+
<!--- INDEX kotlinx.coroutines.guava -->
274+
[ListenableFuture.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-guava/kotlinx.coroutines.guava/com.google.common.util.concurrent.-listenable-future/await.html
275+
<!--- MODULE kotlinx-coroutines-play-services -->
276+
<!--- INDEX kotlinx.coroutines.tasks -->
277+
[Task.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-play-services/kotlinx.coroutines.tasks/com.google.android.gms.tasks.-task/await.html
278+
<!--- MODULE kotlinx-coroutines-reactive -->
279+
<!--- INDEX kotlinx.coroutines.reactive -->
280+
[Publisher.collect]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/org.reactivestreams.-publisher/collect.html
281+
[Publisher.awaitSingle]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/org.reactivestreams.-publisher/await-single.html
282+
[publish]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/publish.html
283+
<!--- MODULE kotlinx-coroutines-rx2 -->
284+
<!--- INDEX kotlinx.coroutines.rx2 -->
285+
[rxFlowable]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/rx-flowable.html
286+
[rxSingle]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/rx-single.html
287+
<!--- MODULE kotlinx-coroutines-reactor -->
288+
<!--- INDEX kotlinx.coroutines.reactor -->
289+
[flux]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/flux.html
290+
[mono]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/mono.html
291+
<!--- END -->

knit/src/Knit.kt

+17-9
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ data class ApiIndexKey(
505505

506506
val apiIndexCache: MutableMap<ApiIndexKey, Map<String, List<String>>> = HashMap()
507507

508-
val REF_LINE_REGEX = Regex("<a href=\"([a-z_/.\\-]+)\">([a-zA-z.]+)</a>")
508+
val REF_LINE_REGEX = Regex("<a href=\"([a-z0-9_/.\\-]+)\">([a-zA-z0-9.]+)</a>")
509509
val INDEX_HTML = "/index.html"
510510
val INDEX_MD = "/index.md"
511511
val FUNCTIONS_SECTION_HEADER = "### Functions"
@@ -526,33 +526,41 @@ fun loadApiIndex(
526526
pkg: String,
527527
namePrefix: String = ""
528528
): Map<String, MutableList<String>>? {
529-
val fileName = docsRoot + "/" + path + INDEX_MD
529+
val fileName = "$docsRoot/$path$INDEX_MD"
530530
val visited = mutableSetOf<String>()
531531
val map = HashMap<String, MutableList<String>>()
532532
var inFunctionsSection = false
533-
File(fileName).withLineNumberReader<LineNumberReader>(::LineNumberReader) {
533+
File(fileName).withLineNumberReader(::LineNumberReader) {
534534
while (true) {
535535
val line = readLine() ?: break
536536
if (line == FUNCTIONS_SECTION_HEADER) inFunctionsSection = true
537537
val result = REF_LINE_REGEX.matchEntire(line) ?: continue
538538
val link = result.groups[1]!!.value
539539
if (link.startsWith("..")) continue // ignore cross-references
540-
val absLink = path + "/" + link
540+
val absLink = "$path/$link"
541541
var name = result.groups[2]!!.value
542542
// a special disambiguation fix for pseudo-constructor functions
543543
if (inFunctionsSection && name[0] in 'A'..'Z') name += "()"
544544
val refName = namePrefix + name
545-
val fqName = pkg + "." + refName
546-
// Put short names for extensions on 3rd party classes (prefix is FQname of those classes)
547-
if (namePrefix != "" && namePrefix[0] in 'a'..'z') map.putUnambiguous(name, absLink)
545+
val fqName = "$pkg.$refName"
546+
// Put shorter names for extensions on 3rd party classes (prefix is FQname of those classes)
547+
if (namePrefix != "" && namePrefix[0] in 'a'..'z') {
548+
val i = namePrefix.dropLast(1).lastIndexOf('.')
549+
if (i >= 0) map.putUnambiguous(namePrefix.substring(i + 1) + name, absLink)
550+
map.putUnambiguous(name, absLink)
551+
}
552+
// Disambiguate lower-case names with leading underscore (e.g. Flow class vs flow builder ambiguity)
553+
if (namePrefix == "" && name[0] in 'a'..'z') {
554+
map.putUnambiguous("_$name", absLink)
555+
}
548556
// Always put fully qualified names
549557
map.putUnambiguous(refName, absLink)
550558
map.putUnambiguous(fqName, absLink)
551559
if (link.endsWith(INDEX_HTML)) {
552560
if (visited.add(link)) {
553561
val path2 = path + "/" + link.substring(0, link.length - INDEX_HTML.length)
554-
map += loadApiIndex(docsRoot, path2, pkg, refName + ".")
555-
?: throw IllegalArgumentException("Failed to parse ${docsRoot + "/" + path2}")
562+
map += loadApiIndex(docsRoot, path2, pkg, "$refName.")
563+
?: throw IllegalArgumentException("Failed to parse $docsRoot/$path2")
556564
}
557565
}
558566
}

0 commit comments

Comments
 (0)