@@ -37,14 +37,31 @@ tasks.withType(DokkaTaskPartial::class).configureEach {
37
37
}
38
38
}
39
39
40
- // Custom configuration for MPP modules
41
- tasks.withType(DokkaTaskPartial ::class ).configureEach {
42
- dokkaSourceSets.configureEach {
43
- sourceLink {
44
- val relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
45
- localDirectory.set(projectDir.resolve(" src" ))
46
- remoteUrl.set(URL (" https://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath /src" ))
47
- remoteLineSuffix.set(" #L" )
40
+ fun GradleDokkaSourceSetBuilder.makeLinkMapping (projectDir : File ) {
41
+ sourceLink {
42
+ val relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
43
+ localDirectory.set(projectDir.resolve(" src" ))
44
+ remoteUrl.set(URL (" https://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath /src" ))
45
+ remoteLineSuffix.set(" #L" )
46
+ }
47
+ }
48
+
49
+ if (project.isMultiplatform) {
50
+ // Configuration for MPP modules
51
+ tasks.withType(DokkaTaskPartial ::class ).configureEach {
52
+ // sources in MPP are located in moduleDir/PLATFORM/src,
53
+ // where PLATFORM could be jvm, js, jdk8, concurrent, etc
54
+ // configuration happens in buildSrc/src/main/kotlin/SourceSetsKt.configureMultiplatform
55
+ dokkaSourceSets.matching { it.name.endsWith(" Main" ) }.configureEach {
56
+ val platform = name.dropLast(4 )
57
+ makeLinkMapping(project.file(platform))
58
+ }
59
+ }
60
+ } else {
61
+ // Configuration for JVM modules
62
+ tasks.withType(DokkaTaskPartial ::class ).configureEach {
63
+ dokkaSourceSets.named(" main" ) {
64
+ makeLinkMapping(projectDir)
48
65
}
49
66
}
50
67
}
0 commit comments