Skip to content

Commit 2f4196f

Browse files
authored
Update Gradle dokka configuration to make sure "source" button is visible in all API docs (#244)
1 parent 7fb9df4 commit 2f4196f

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

build-logic/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ repositories {
1313

1414
dependencies {
1515
implementation(libs.kotlin.gradle.plugin)
16+
implementation(libs.dokka.gradle.plugin)
1617
implementation(libs.animalsniffer.gradle.plugin)
1718
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2017-2023 JetBrains s.r.o. and respective authors and developers.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
4+
*/
5+
6+
import org.jetbrains.dokka.gradle.*
7+
import java.net.*
8+
9+
plugins {
10+
id("org.jetbrains.dokka")
11+
}
12+
13+
tasks.withType<DokkaTaskPartial>().configureEach {
14+
dokkaSourceSets.configureEach {
15+
includes.from("Module.md")
16+
17+
if (name.endsWith("Main")) {
18+
sourceLink {
19+
// sources are located in projectDir/PLATFORM/src
20+
// where the PLATFORM could be jvm, js, darwin, etc.
21+
// configuration happens in kotlinx-io-multiplatform.gradle.kts:KotlinSourceSet.configureSourceSet
22+
val platform = name.dropLast(4)
23+
val relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
24+
localDirectory.set(projectDir.resolve("$platform/src"))
25+
remoteUrl.set(URL("https://github.com/kotlin/kotlinx-io/tree/master/$relPath/$platform/src"))
26+
remoteLineSuffix.set("#L")
27+
}
28+
}
29+
}
30+
}

bytestring/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
33
plugins {
44
id("kotlinx-io-multiplatform")
55
id("kotlinx-io-publish")
6+
id("kotlinx-io-dokka")
67
id("kotlinx-io-android-compat")
78
alias(libs.plugins.kover)
8-
alias(libs.plugins.dokka)
99
}
1010

1111
kotlin {
@@ -30,8 +30,6 @@ kotlin {
3030

3131
tasks.withType<DokkaTaskPartial>().configureEach {
3232
dokkaSourceSets.configureEach {
33-
includes.from("Module.md")
34-
3533
perPackageOption {
3634
suppress.set(true)
3735
matchingRegex.set(".*unsafe.*")

core/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
88
plugins {
99
id("kotlinx-io-multiplatform")
1010
id("kotlinx-io-publish")
11+
id("kotlinx-io-dokka")
1112
id("kotlinx-io-android-compat")
1213
alias(libs.plugins.kover)
13-
alias(libs.plugins.dokka)
1414
}
1515

1616
kotlin {
@@ -59,8 +59,6 @@ kotlin {
5959

6060
tasks.withType<DokkaTaskPartial>().configureEach {
6161
dokkaSourceSets.configureEach {
62-
includes.from("Module.md")
63-
6462
samples.from(
6563
"common/test/samples/rawSinkSample.kt",
6664
"common/test/samples/rawSourceSample.kt",

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ animalsniffer = "1.7.1"
1313

1414
kotlinx-benchmark-runtime = { group = "org.jetbrains.kotlinx", name = "kotlinx-benchmark-runtime", version.ref = "benchmark" }
1515
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
16+
dokka-gradle-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "dokka" }
1617
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
1718
animalsniffer-gradle-plugin = { group = "ru.vyarus", name = "gradle-animalsniffer-plugin", version.ref = "animalsniffer" }
1819

0 commit comments

Comments
 (0)