Skip to content

Commit f5172c5

Browse files
authored
Fix dokka API button for all modules (#381)
1 parent 25a42ab commit f5172c5

File tree

3 files changed

+41
-21
lines changed

3 files changed

+41
-21
lines changed

gradle-conventions/src/main/kotlin/conventions-dokka-spec.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
66
import util.KOTLINX_RPC_PREFIX
77
import util.other.libs
8-
import java.time.Year
8+
import util.setupPage
99

1010
plugins {
1111
id("org.jetbrains.dokka")
1212
}
1313

1414
dokka {
15+
val globalRootDir: String by project.extra
16+
1517
pluginsConfiguration {
1618
html {
17-
footerMessage = "© ${Year.now()} JetBrains s.r.o and contributors. Apache License 2.0"
19+
setupPage(globalRootDir)
1820
}
1921
}
2022

gradle-conventions/src/main/kotlin/conventions-root.gradle.kts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import util.other.isPublicModule
66
import util.other.libs
77
import util.other.maybeNamed
8+
import util.setupPage
89
import util.tasks.ValidatePublishedArtifactsTask
910
import util.tasks.configureNpm
1011
import util.tasks.registerChangelogTask
1112
import util.tasks.registerDumpPlatformTableTask
1213
import util.tasks.registerVerifyPlatformTableTask
13-
import java.time.Year
1414
import kotlin.io.path.exists
1515
import kotlin.io.path.isDirectory
1616
import kotlin.io.path.listDirectoryEntries
@@ -46,29 +46,19 @@ dokka {
4646

4747
moduleVersion.set(libVersion)
4848

49-
val pagesDirectory = layout.projectDirectory
50-
.dir("docs")
51-
.dir("pages")
49+
val globalRootDir: String by project.extra
5250

53-
val dokkaVersionsDirectory = pagesDirectory
54-
.dir("api")
55-
.asFile
51+
val pagesDirectory = kotlin.io.path.Path(globalRootDir)
52+
.resolve("docs")
53+
.resolve("pages")
5654

57-
val templatesDirectory = pagesDirectory
58-
.dir("templates")
55+
val dokkaVersionsDirectory = pagesDirectory
56+
.resolve("api")
57+
.toFile()
5958

6059
pluginsConfiguration {
6160
html {
62-
customAssets.from(
63-
"docs/pages/assets/logo-icon.svg",
64-
"docs/pages/assets/homepage.svg", // Doesn't work due to https://github.com/Kotlin/dokka/issues/4007
65-
)
66-
67-
footerMessage = "© ${Year.now()} JetBrains s.r.o and contributors. Apache License 2.0"
68-
homepageLink = "https://kotlin.github.io/kotlinx-rpc/get-started.html"
69-
70-
// replace with homepage.svg once the mentioned issue is resolved
71-
templatesDir.set(templatesDirectory)
61+
setupPage(globalRootDir)
7262
}
7363
}
7464

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package util
6+
7+
import org.gradle.kotlin.dsl.assign
8+
import org.jetbrains.dokka.gradle.engine.plugins.DokkaHtmlPluginParameters
9+
import java.time.Year
10+
11+
fun DokkaHtmlPluginParameters.setupPage(globalRootDir: String) {
12+
val templatesDirectory = kotlin.io.path.Path(globalRootDir)
13+
.resolve("docs")
14+
.resolve("pages")
15+
.resolve("templates")
16+
.toFile()
17+
18+
customAssets.from(
19+
"$globalRootDir/docs/pages/assets/logo-icon.svg",
20+
"$globalRootDir/docs/pages/assets/homepage.svg", // Doesn't work due to https://github.com/Kotlin/dokka/issues/4007
21+
)
22+
23+
footerMessage = "© ${Year.now()} JetBrains s.r.o and contributors. Apache License 2.0"
24+
homepageLink = "https://kotlin.github.io/kotlinx-rpc/get-started.html"
25+
26+
// replace with homepage.svg once the mentioned issue is resolved
27+
templatesDir.set(templatesDirectory)
28+
}

0 commit comments

Comments
 (0)