Skip to content

Commit 93962a8

Browse files
authored
Update Gradle dokka configuration to make sure "source" button is visible in all API docs (#2518)
1 parent e997d3e commit 93962a8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

gradle/dokka.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def documentedSubprojects = ["kotlinx-serialization-core",
1212
"kotlinx-serialization-properties",
1313
"kotlinx-serialization-hocon",
1414
"kotlinx-serialization-protobuf"]
15+
16+
def jvmOnlySubprojects = ["kotlinx-serialization-hocon"]
17+
1518
subprojects {
1619
if (!(name in documentedSubprojects)) return
1720
apply plugin: 'org.jetbrains.dokka'
@@ -72,6 +75,16 @@ subprojects {
7275
matchingRegex.set("org\\.intellij\\.lang\\.annotations(\$|\\.).*")
7376
suppress.set(true)
7477
}
78+
79+
sourceLink {
80+
// sources directory for MPP configured in gradle/configure-source-sets.gradle:61
81+
// in short - kotlin.srcDirs = ["$sourceSet.name/src"]
82+
def sourcesPath = project.name in jvmOnlySubprojects ? "src/main/kotlin" : "$name/src"
83+
def relProjectPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
84+
localDirectory.set(file(sourcesPath))
85+
remoteUrl.set(new URL("https://github.com/Kotlin/kotlinx.serialization/tree/master/$relProjectPath/$sourcesPath"))
86+
remoteLineSuffix.set("#L")
87+
}
7588
}
7689
}
7790
}

0 commit comments

Comments
 (0)