diff --git a/build.gradle.kts b/build.gradle.kts index 7b9248ca49..8c1f95e770 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -90,6 +90,7 @@ allprojects { */ google() mavenCentral() + maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") addDevRepositoryIfEnabled(this, project) } } diff --git a/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts b/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts index 966aa98e04..a891ffcadc 100644 --- a/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts @@ -7,6 +7,7 @@ plugins { } val knit_version: String by project +val storytale_version: String by project private val projetsWithoutDokka = unpublished + "kotlinx-coroutines-bom" + jdk8ObsoleteModule private val coreModuleDocsUrl = "https://kotlinlang.org/api/kotlinx.coroutines/$coreModule/" private val coreModuleDocsPackageList = "$projectDir/kotlinx-coroutines-core/build/dokka/htmlPartial/package-list" @@ -14,6 +15,7 @@ private val coreModuleDocsPackageList = "$projectDir/kotlinx-coroutines-core/bui configure(subprojects.filterNot { projetsWithoutDokka.contains(it.name) }) { apply(plugin = "org.jetbrains.dokka") configurePathsaver() + configureStorytale() condigureDokkaSetup() configureExternalLinks() } @@ -37,6 +39,12 @@ private fun Project.configurePathsaver() { } } +private fun Project.configureStorytale() { + dependencies { + dokkaPlugin("org.jetbrains.compose.storytale:storytale-dokka-plugin:$storytale_version") + } +} + // Configure Dokka setup private fun Project.condigureDokkaSetup() { tasks.withType(DokkaTaskPartial::class).configureEach { @@ -91,9 +99,13 @@ private fun Project.configureExternalLinks() { * - Templates repository: https://github.com/JetBrains/kotlin-web-site/tree/master/dokka-templates */ private fun Project.setupDokkaTemplatesDir(dokkaTask: AbstractDokkaTask) { - dokkaTask.pluginsMapConfiguration = mapOf( - "org.jetbrains.dokka.base.DokkaBase" to """{ "templatesDir" : "${ - project.rootProject.projectDir.toString().replace('\\', '/') - }/dokka-templates" }""" - ) + val rootDir = project.rootProject.projectDir.toString().replace('\\', '/') + //language=JSON + val dokkaBaseConfiguration = """ + { + "customStyleSheets": ["$rootDir/dokka-templates/styles/storytale-styles.css"], + "templatesDir": "$rootDir/dokka-templates" + } + """ + dokkaTask.pluginsMapConfiguration = mapOf("org.jetbrains.dokka.base.DokkaBase" to dokkaBaseConfiguration) } diff --git a/dokka-templates/styles/storytale-styles.css b/dokka-templates/styles/storytale-styles.css new file mode 100644 index 0000000000..f2f6f06d0c --- /dev/null +++ b/dokka-templates/styles/storytale-styles.css @@ -0,0 +1,28 @@ +.storytale-embedded-container { + container-type: inline-size; +} + +.storytale-embedded { + min-height: 450px; + border: 1px solid lightgray; + border-radius: 8px; + overflow: hidden; +} + +@container (max-width: 800px) { + .storytale-embedded { + aspect-ratio: 1 / 1; + } +} + +@container (max-width: 700px) { + .storytale-embedded { + aspect-ratio: 15 / 16; + } +} + +@container (max-width: 500px) { + .storytale-embedded { + aspect-ratio: 3 / 4; + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7af5770c35..db0c84e826 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,7 @@ benchmarks_jmh_version=1.37 junit_version=4.12 junit5_version=5.7.0 knit_version=0.5.0 +storytale_version=0.0.4-alpha01+dev18 lincheck_version=2.18.1 dokka_version=2.0.0 byte_buddy_version=1.10.9 diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt b/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt index 2a701c0c12..7bd66c4d9a 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt @@ -26,6 +26,8 @@ fun main() = runBlocking { */ /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Debounce + * * Returns a flow that mirrors the original flow, but filters out values * that are followed by the newer values within the given [timeout][timeoutMillis]. * The latest value is always emitted. diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Distinct.kt b/kotlinx-coroutines-core/common/src/flow/operators/Distinct.kt index 78e4d71a89..865373bf22 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Distinct.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Distinct.kt @@ -31,6 +31,8 @@ public fun Flow.distinctUntilChanged(areEquivalent: (old: T, new: T) -> B distinctUntilChangedBy(keySelector = defaultKeySelector, areEquivalent = areEquivalent as (Any?, Any?) -> Boolean) /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/DistinctUntilChanged + * * Returns flow where all subsequent repetitions of the same key are filtered out, where * key is extracted with [keySelector] function. * diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt b/kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt index ceeb336392..2928c0a710 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt @@ -13,6 +13,8 @@ import kotlin.jvm.* // user code to directly emit to the underlying FlowCollector. /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Transform + * * Applies [transform] function to each value of the given flow. * * The receiver of the `transform` is [FlowCollector] and thus `transform` is a diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Limit.kt b/kotlinx-coroutines-core/common/src/flow/operators/Limit.kt index 2c37e24162..1cc7063006 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Limit.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Limit.kt @@ -11,6 +11,8 @@ import kotlinx.coroutines.flow.flow as safeFlow import kotlinx.coroutines.flow.internal.unsafeFlow as flow /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Drop + * * Returns a flow that ignores first [count] elements. * Throws [IllegalArgumentException] if [count] is negative. */ @@ -25,6 +27,8 @@ public fun Flow.drop(count: Int): Flow { } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/DropWhile + * * Returns a flow containing all elements except first elements that satisfy the given predicate. */ public fun Flow.dropWhile(predicate: suspend (T) -> Boolean): Flow = flow { @@ -40,6 +44,8 @@ public fun Flow.dropWhile(predicate: suspend (T) -> Boolean): Flow = f } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Take + * * Returns a flow that contains first [count] elements. * When [count] elements are consumed, the original flow is cancelled. * Throws [IllegalArgumentException] if [count] is not positive. @@ -73,6 +79,8 @@ private suspend fun FlowCollector.emitAbort(value: T, ownershipMarker: An } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/TakeWhile + * * Returns a flow that contains first elements satisfying the given [predicate]. * * Note, that the resulting flow does not contain the element on which the [predicate] returned `false`. @@ -91,6 +99,8 @@ public fun Flow.takeWhile(predicate: suspend (T) -> Boolean): Flow = f } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/TransformWhile + * * Applies [transform] function to each value of the given flow while this * function returns `true`. * diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt b/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt index 92ebeabbaa..1f67c2cd6f 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt @@ -30,6 +30,8 @@ public val DEFAULT_CONCURRENCY: Int = systemProp( ) /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/FlatMapConcat + * * Transforms elements emitted by the original flow by applying [transform], that returns another flow, * and then concatenating and flattening these flows. * @@ -43,6 +45,8 @@ public fun Flow.flatMapConcat(transform: suspend (value: T) -> Flow map(transform).flattenConcat() /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/FlatMapMerge + * * Transforms elements emitted by the original flow by applying [transform], that returns another flow, * and then merging and flattening these flows. * @@ -103,6 +107,8 @@ public fun Iterable>.merge(): Flow { } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Merge + * * Merges the given flows into a single flow without preserving an order of elements. * All flows are merged concurrently, without limit on the number of simultaneously collected flows. * @@ -138,6 +144,8 @@ public fun Flow>.flattenMerge(concurrency: Int = DEFAULT_CONCURRENCY } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/TransformLatest + * * Returns a flow that produces element by [transform] function every time the original flow emits a value. * When the original flow emits a new value, the previous `transform` block is cancelled, thus the name `transformLatest`. * @@ -163,6 +171,8 @@ public fun Flow.transformLatest(@BuilderInference transform: suspend F ChannelFlowTransformLatest(transform, this) /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/FlatMapLatest + * * Returns a flow that switches to a new flow produced by [transform] function every time the original flow emits a value. * When the original flow emits a new value, the previous flow produced by `transform` block is cancelled. * @@ -189,6 +199,8 @@ public inline fun Flow.flatMapLatest(@BuilderInference crossinline tra transformLatest { emitAll(transform(it)) } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/MapLatest + * * Returns a flow that emits elements from the original flow transformed by [transform] function. * When the original flow emits a new value, computation of the [transform] block for previous value is cancelled. * diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Transform.kt b/kotlinx-coroutines-core/common/src/flow/operators/Transform.kt index f3c9be1c7e..9ec97217c2 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Transform.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Transform.kt @@ -12,6 +12,8 @@ import kotlinx.coroutines.flow.internal.unsafeFlow as flow import kotlinx.coroutines.flow.unsafeTransform as transform /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Filter + * * Returns a flow containing only values of the original flow that match the given [predicate]. */ public inline fun Flow.filter(crossinline predicate: suspend (T) -> Boolean): Flow = transform { value -> @@ -44,6 +46,8 @@ public fun Flow.filterNotNull(): Flow = transform { value } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Map + * * Returns a flow containing the results of applying the given [transform] function to each value of the original flow. */ public inline fun Flow.map(crossinline transform: suspend (value: T) -> R): Flow = transform { value -> @@ -59,6 +63,8 @@ public inline fun Flow.mapNotNull(crossinline transform: suspend } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/WithIndex + * * Returns a flow that wraps each element into [IndexedValue], containing value and its index (starting from zero). */ public fun Flow.withIndex(): Flow> = flow { @@ -108,6 +114,8 @@ public fun Flow.runningFold(initial: R, @BuilderInference operation: s } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/RunningReduce + * * Reduces the given flow with [operation], emitting every intermediate result, including initial value. * The first element is taken as initial value for operation accumulator. * This operator has a sibling with initial value -- [scan]. diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Zip.kt b/kotlinx-coroutines-core/common/src/flow/operators/Zip.kt index 3b9237eda8..6f928dba6a 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Zip.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Zip.kt @@ -10,6 +10,8 @@ import kotlinx.coroutines.flow.flow as safeFlow import kotlinx.coroutines.flow.internal.unsafeFlow as flow /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Combine + * * Returns a [Flow] whose values are generated with [transform] function by combining * the most recently emitted values by each flow. * @@ -306,6 +308,8 @@ public inline fun combineTransform( } /** + * @story https://jsmonk.github.io/FlowMarbles/?embedded=true#story/Zip + * * Zips values from the current flow (`this`) with [other] flow using provided [transform] function applied to each pair of values. * The resulting flow completes as soon as one of the flows completes and cancel is called on the remaining flow. *