Skip to content

Commit a9fff4c

Browse files
authored
Merge pull request #175 from simple-robot/dev/upgrade-dokka
更新Dokka到2.0.0
2 parents 3eb789f + 5c3d611 commit a9fff4c

File tree

16 files changed

+386
-274
lines changed

16 files changed

+386
-274
lines changed

.github/workflows/publish-kdoc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
with:
3737
gradle-version: ${{ env.GRADLE_VERSION }}
3838
arguments: |
39-
dokkaHtmlMultiModule
39+
dokkaGenerate
4040
--info
4141
--warning-mode all
4242
-x test

.github/workflows/publish-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ jobs:
132132
with:
133133
gradle-version: ${{ env.GRADLE_VERSION }}
134134
arguments: |
135-
dokkaHtmlMultiModule
135+
dokkaGenerate
136136
--info
137137
--warning-mode all
138138
-x test

.github/workflows/publish-snapshot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113
with:
114114
gradle-version: ${{ env.GRADLE_VERSION }}
115115
arguments: |
116-
dokkaHtmlMultiModule
116+
dokkaGenerate
117117
-Porg.gradle.jvmargs="-Xmx4g -Xms4g -XX:MaxMetaspaceSize=2g -Dfile.encoding=UTF-8"
118118
-Porg.gradle.daemon=false
119119
--info

build.gradle.kts

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import util.isCi
2424

2525
plugins {
2626
idea
27+
id("org.jetbrains.dokka")
2728
`simbot-onebot-nexus-publish`
28-
`simbot-onebot-dokka-multi-module`
2929
`simbot-onebot-changelog-generator`
30-
3130
alias(libs.plugins.detekt)
3231
alias(libs.plugins.kotlinxBinaryCompatibilityValidator)
3332
alias(libs.plugins.suspendTransform) apply false
@@ -86,7 +85,7 @@ idea {
8685
}
8786
}
8887

89-
// detekt
88+
//region detekt
9089
dependencies {
9190
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:${libs.versions.detekt.get()}")
9291
}
@@ -125,6 +124,7 @@ tasks.withType<Detekt>().configureEach {
125124
exclude("**/test/kotlin/")
126125
exclude("**/test/java/")
127126
}
127+
//endregion
128128

129129
apiValidation {
130130
ignoredPackages.add("*.internal.*")
@@ -151,3 +151,51 @@ apiValidation {
151151

152152
apiDumpDirectory = "api"
153153
}
154+
155+
// region Dokka
156+
157+
// childProjects.values.forEach { childProject ->
158+
// childProject.afterEvaluate {
159+
// if (childProject.plugins.hasPlugin(libs.plugins.dokka.get().pluginId)) {
160+
// dokka {
161+
// configSourceSets(childProject)
162+
// configHtmlCustoms(childProject)
163+
// }
164+
// rootProject.dependencies.dokka(childProject)
165+
// }
166+
// }
167+
// }
168+
169+
subprojects {
170+
afterEvaluate {
171+
val p = this
172+
if (plugins.hasPlugin(libs.plugins.dokka.get().pluginId)) {
173+
dokka {
174+
configSourceSets(p)
175+
pluginsConfiguration.html {
176+
configHtmlCustoms(project)
177+
}
178+
}
179+
rootProject.dependencies.dokka(p)
180+
}
181+
}
182+
}
183+
184+
dokka {
185+
moduleName = "Simple Robot 组件 | OneBot"
186+
187+
dokkaPublications.all {
188+
if (isSimbotLocal()) {
189+
logger.info("Is 'SIMBOT_LOCAL', offline")
190+
offlineMode = true
191+
}
192+
}
193+
194+
configSourceSets(project)
195+
196+
pluginsConfiguration.html {
197+
configHtmlCustoms(project)
198+
}
199+
}
200+
// endregion
201+

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ val kotlinVersion: String = libs.versions.kotlin.get()
3131
dependencies {
3232
implementation(kotlin("gradle-plugin", kotlinVersion))
3333
implementation(kotlin("serialization", kotlinVersion))
34-
implementation(libs.bundles.dokka)
34+
implementation(libs.dokka.plugin)
3535

3636
// see https://github.com/gradle-nexus/publish-plugin
3737
implementation("io.github.gradle-nexus:publish-plugin:2.0.0")
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import org.gradle.api.Project
2+
import org.gradle.api.tasks.compile.JavaCompile
3+
import org.jetbrains.dokka.gradle.DokkaExtension
4+
import org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceSetSpec
5+
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
6+
import org.jetbrains.dokka.gradle.engine.plugins.DokkaHtmlPluginParameters
7+
import java.io.File
8+
import java.net.URI
9+
import java.time.Year
10+
11+
/*
12+
* Copyright (c) 2025. ForteScarlet.
13+
*
14+
* This file is part of simbot-component-onebot.
15+
*
16+
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
17+
* of the GNU Lesser General Public License as published by the Free Software Foundation,
18+
* either version 3 of the License, or (at your option) any later version.
19+
*
20+
* simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
21+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22+
* See the GNU Lesser General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
25+
* If not, see <https://www.gnu.org/licenses/>.
26+
*/
27+
28+
fun DokkaExtension.configSourceSets(project: Project) {
29+
dokkaSourceSets.configureEach {
30+
skipEmptyPackages.set(true)
31+
suppressGeneratedFiles.set(false)
32+
documentedVisibilities(
33+
VisibilityModifier.Public,
34+
VisibilityModifier.Protected
35+
)
36+
project.tasks.withType(JavaCompile::class.java).firstOrNull()
37+
?.targetCompatibility?.toInt().also {
38+
logger.info("project {} found jdkVersionValue: {}", project, it)
39+
}?.also {
40+
jdkVersion.set(it)
41+
}
42+
43+
configModuleMdInclude(project)
44+
45+
perPackageOption {
46+
matchingRegex.set(".*internal.*") // will match all .internal packages and sub-packages
47+
suppress.set(true)
48+
}
49+
50+
configSourceLink(project)
51+
52+
configExternalDocumentations()
53+
}
54+
}
55+
56+
fun DokkaSourceSetSpec.configModuleMdInclude(project: Project) {
57+
val moduleFile = project.file("Module.md")
58+
if (moduleFile.exists() && moduleFile.length() > 0) {
59+
includes.from("Module.md")
60+
}
61+
}
62+
63+
fun DokkaSourceSetSpec.configSourceLink(project: Project) {
64+
sourceLink {
65+
localDirectory.set(File(project.projectDir, "src"))
66+
val relativeTo = project.projectDir.relativeTo(project.rootProject.projectDir).toString()
67+
.replace('\\', '/')
68+
remoteUrl.set(URI.create("${P.ComponentOneBot.HOMEPAGE}/tree/dev/main/$relativeTo/src"))
69+
remoteLineSuffix.set("#L")
70+
}
71+
}
72+
73+
fun DokkaSourceSetSpec.configExternalDocumentations() {
74+
fun externalDocumentation(name: String, docUrl: URI, suffix: String = "package-list") {
75+
externalDocumentationLinks.register(name) {
76+
url.set(docUrl)
77+
packageListUrl.set(docUrl.resolve(suffix))
78+
}
79+
}
80+
81+
// kotlin-coroutines doc
82+
externalDocumentation(
83+
"kotlinx.coroutines",
84+
URI.create("https://kotlinlang.org/api/kotlinx.coroutines/")
85+
)
86+
87+
// kotlin-serialization doc
88+
externalDocumentation(
89+
"kotlinx.serialization",
90+
URI.create("https://kotlinlang.org/api/kotlinx.serialization/")
91+
)
92+
93+
// ktor
94+
externalDocumentation(
95+
"ktor",
96+
URI.create("https://api.ktor.io/")
97+
)
98+
99+
// SLF4J
100+
externalDocumentation(
101+
"slf4j",
102+
URI.create("https://www.slf4j.org/apidocs/"),
103+
"element-list"
104+
)
105+
}
106+
107+
fun DokkaHtmlPluginParameters.configHtmlCustoms(project: Project) {
108+
customAssets.from(
109+
project.rootProject.file(".simbot/dokka-assets/logo-icon.svg"),
110+
project.rootProject.file(".simbot/dokka-assets/logo-icon-light.svg"),
111+
)
112+
113+
customStyleSheets.from(project.rootProject.file(".simbot/dokka-assets/css/kdoc-style.css"))
114+
115+
if (!isSimbotLocal()) {
116+
templatesDir.set(project.rootProject.file(".simbot/dokka-templates"))
117+
}
118+
119+
val now = Year.now().value
120+
footerMessage.set(
121+
"© 2024-$now " +
122+
"<a href='https://github.com/simple-robot'>Simple Robot</a>. All rights reserved."
123+
)
124+
125+
separateInheritedMembers.set(true)
126+
mergeImplicitExpectActualDeclarations.set(true)
127+
homepageLink.set(P.ComponentOneBot.HOMEPAGE)
128+
}
Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
/*
2-
* Copyright (c) 2024. ForteScarlet.
3-
*
4-
* This file is part of simbot-component-onebot.
5-
*
6-
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
7-
* of the GNU Lesser General Public License as published by the Free Software Foundation,
8-
* either version 3 of the License, or (at your option) any later version.
9-
*
10-
* simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11-
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Lesser General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
15-
* If not, see <https://www.gnu.org/licenses/>.
16-
*/
17-
18-
19-
import org.jetbrains.dokka.base.DokkaBase
20-
import org.jetbrains.dokka.base.DokkaBaseConfiguration
21-
import java.time.Year
22-
23-
plugins {
24-
id("org.jetbrains.dokka")
25-
}
26-
27-
repositories {
28-
mavenCentral()
29-
}
30-
31-
fun org.jetbrains.dokka.gradle.AbstractDokkaTask.configOutput(format: String) {
32-
moduleName.set("Simple Robot 组件 | OneBot")
33-
outputDirectory.set(rootProject.file("build/dokka/$format"))
34-
}
35-
36-
@Suppress("MaxLineLength")
37-
tasks.named<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("dokkaHtmlMultiModule") {
38-
configOutput("html")
39-
if (isSimbotLocal()) {
40-
offlineMode.set(true)
41-
}
42-
// rootProject.file("README.md").takeIf { it.exists() }?.also {
43-
// includes.from(it)
44-
// }
45-
46-
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
47-
customAssets = listOf(
48-
rootProject.file(".simbot/dokka-assets/logo-icon.svg"),
49-
rootProject.file(".simbot/dokka-assets/logo-icon-light.svg"),
50-
)
51-
customStyleSheets = listOf(rootProject.file(".simbot/dokka-assets/css/kdoc-style.css"))
52-
if (!isSimbotLocal()) {
53-
templatesDir = rootProject.file(".simbot/dokka-templates")
54-
}
55-
val now = Year.now().value
56-
val yearRange = if (now == 2024) "2024" else "2024-$now"
57-
footerMessage = "© $yearRange <a href='https://github.com/simple-robot'>Simple Robot</a>. All rights reserved."
58-
separateInheritedMembers = true
59-
mergeImplicitExpectActualDeclarations = true
60-
homepageLink = P.ComponentOneBot.HOMEPAGE
61-
}
62-
}
63-
1+
// /*
2+
// * Copyright (c) 2024. ForteScarlet.
3+
// *
4+
// * This file is part of simbot-component-onebot.
5+
// *
6+
// * simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
7+
// * of the GNU Lesser General Public License as published by the Free Software Foundation,
8+
// * either version 3 of the License, or (at your option) any later version.
9+
// *
10+
// * simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11+
// * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
// * See the GNU Lesser General Public License for more details.
13+
// *
14+
// * You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
15+
// * If not, see <https://www.gnu.org/licenses/>.
16+
// */
17+
//
18+
//
19+
// import org.jetbrains.dokka.base.DokkaBase
20+
// import org.jetbrains.dokka.base.DokkaBaseConfiguration
21+
// import java.time.Year
22+
//
23+
// plugins {
24+
// id("org.jetbrains.dokka")
25+
// }
26+
//
27+
// repositories {
28+
// mavenCentral()
29+
// }
30+
//
31+
// fun org.jetbrains.dokka.gradle.AbstractDokkaTask.configOutput(format: String) {
32+
// moduleName.set("Simple Robot 组件 | OneBot")
33+
// outputDirectory.set(rootProject.file("build/dokka/$format"))
34+
// }
35+
//
36+
// @Suppress("MaxLineLength")
37+
// tasks.named<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("dokkaHtmlMultiModule") {
38+
// configOutput("html")
39+
// if (isSimbotLocal()) {
40+
// offlineMode.set(true)
41+
// }
42+
// // rootProject.file("README.md").takeIf { it.exists() }?.also {
43+
// // includes.from(it)
44+
// // }
45+
//
46+
// pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
47+
// customAssets = listOf(
48+
// rootProject.file(".simbot/dokka-assets/logo-icon.svg"),
49+
// rootProject.file(".simbot/dokka-assets/logo-icon-light.svg"),
50+
// )
51+
// customStyleSheets = listOf(rootProject.file(".simbot/dokka-assets/css/kdoc-style.css"))
52+
// if (!isSimbotLocal()) {
53+
// templatesDir = rootProject.file(".simbot/dokka-templates")
54+
// }
55+
// val now = Year.now().value
56+
// val yearRange = if (now == 2024) "2024" else "2024-$now"
57+
// footerMessage = "© $yearRange <a href='https://github.com/simple-robot'>Simple Robot</a>. All rights reserved."
58+
// separateInheritedMembers = true
59+
// mergeImplicitExpectActualDeclarations = true
60+
// homepageLink = P.ComponentOneBot.HOMEPAGE
61+
// }
62+
// }
63+
//

0 commit comments

Comments
 (0)