diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 14c0f8ec1..1558a0e88 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -13,5 +13,6 @@ repositories { dependencies { implementation(libs.kotlin.gradle.plugin) + implementation(libs.dokka.gradle.plugin) implementation(libs.animalsniffer.gradle.plugin) } diff --git a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-dokka.gradle.kts b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-dokka.gradle.kts new file mode 100644 index 000000000..ae4d46f25 --- /dev/null +++ b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-dokka.gradle.kts @@ -0,0 +1,30 @@ +/* + * Copyright 2017-2023 JetBrains s.r.o. and respective authors and developers. + * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file. + */ + +import org.jetbrains.dokka.gradle.* +import java.net.* + +plugins { + id("org.jetbrains.dokka") +} + +tasks.withType().configureEach { + dokkaSourceSets.configureEach { + includes.from("Module.md") + + if (name.endsWith("Main")) { + sourceLink { + // sources are located in projectDir/PLATFORM/src + // where the PLATFORM could be jvm, js, darwin, etc. + // configuration happens in kotlinx-io-multiplatform.gradle.kts:KotlinSourceSet.configureSourceSet + val platform = name.dropLast(4) + val relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath()) + localDirectory.set(projectDir.resolve("$platform/src")) + remoteUrl.set(URL("https://github.com/kotlin/kotlinx-io/tree/master/$relPath/$platform/src")) + remoteLineSuffix.set("#L") + } + } + } +} diff --git a/bytestring/build.gradle.kts b/bytestring/build.gradle.kts index 4440dc999..d96dd3e70 100644 --- a/bytestring/build.gradle.kts +++ b/bytestring/build.gradle.kts @@ -3,9 +3,9 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial plugins { id("kotlinx-io-multiplatform") id("kotlinx-io-publish") + id("kotlinx-io-dokka") id("kotlinx-io-android-compat") alias(libs.plugins.kover) - alias(libs.plugins.dokka) } kotlin { @@ -30,8 +30,6 @@ kotlin { tasks.withType().configureEach { dokkaSourceSets.configureEach { - includes.from("Module.md") - perPackageOption { suppress.set(true) matchingRegex.set(".*unsafe.*") diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 3746d77e5..9d2f3ebb7 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -8,9 +8,9 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial plugins { id("kotlinx-io-multiplatform") id("kotlinx-io-publish") + id("kotlinx-io-dokka") id("kotlinx-io-android-compat") alias(libs.plugins.kover) - alias(libs.plugins.dokka) } kotlin { @@ -59,8 +59,6 @@ kotlin { tasks.withType().configureEach { dokkaSourceSets.configureEach { - includes.from("Module.md") - samples.from( "common/test/samples/rawSinkSample.kt", "common/test/samples/rawSourceSample.kt", diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c70a25044..40189c9d5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,6 +13,7 @@ animalsniffer = "1.7.1" kotlinx-benchmark-runtime = { group = "org.jetbrains.kotlinx", name = "kotlinx-benchmark-runtime", version.ref = "benchmark" } kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } +dokka-gradle-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "dokka" } kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" } animalsniffer-gradle-plugin = { group = "ru.vyarus", name = "gradle-animalsniffer-plugin", version.ref = "animalsniffer" }