Skip to content

Commit 00187d5

Browse files
authored
Merge pull request #1012 from simple-robot/update-dokka
Update Dokka to 2.0.0
2 parents 27dc175 + 322e5be commit 00187d5

File tree

36 files changed

+356
-395
lines changed

36 files changed

+356
-395
lines changed

.github/workflows/kdoc.yml.bk

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/publish-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ jobs:
121121
uses: gradle/gradle-build-action@v3
122122
with:
123123
gradle-version: 8.3
124-
arguments: |
125-
dokkaHtmlMultiModule
126-
--info
124+
arguments: |
125+
dokkaGenerate
126+
-s
127127
--warning-mode all
128128
-x test
129129
--build-cache

.github/workflows/publish-snapshot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ jobs:
9191
with:
9292
gradle-version: 8.3
9393
arguments: |
94-
dokkaHtmlMultiModule
95-
--info
94+
dokkaGenerate
95+
-s
9696
--warning-mode all
9797
-x test
9898
--build-cache

.github/workflows/publish-v4-kdoc.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818
jobs:
1919
deploy-doc:
2020
name: Deploy V4 API Doc
21-
runs-on: macos-latest
21+
runs-on: ubuntu-latest
2222
steps:
2323
# 检出仓库代码
2424
- uses: actions/checkout@v4
@@ -39,8 +39,8 @@ jobs:
3939
with:
4040
gradle-version: ${{ env.GRADLE_VERSION }}
4141
arguments: |
42-
dokkaHtmlMultiModule
43-
--info
42+
dokkaGenerate
43+
-s
4444
--warning-mode all
4545
-x test
4646
--build-cache

.github/workflows/publish-v4-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ jobs:
133133
with:
134134
gradle-version: ${{ env.GRADLE_VERSION }}
135135
arguments: |
136-
dokkaHtmlMultiModule
137-
--info
136+
dokkaGenerate
137+
-s
138138
--warning-mode all
139139
-x test
140140
--build-cache

.github/workflows/publish-v4-snapshot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
deploy-doc:
104104
name: Deploy snapshots API doc
105105
needs: publish-v4-snapshot
106-
runs-on: macos-latest # ubuntu-latest
106+
runs-on: ubuntu-latest
107107
steps:
108108
# 检出仓库代码
109109
- name: Check out repo
@@ -126,7 +126,7 @@ jobs:
126126
with:
127127
gradle-version: ${{ env.GRADLE_VERSION }}
128128
arguments: |
129-
dokkaHtmlMultiModule
129+
dokkaGenerate
130130
-s
131131
--warning-mode all
132132
-x test

build.gradle.kts

Lines changed: 151 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,27 @@ import changelog.generateChangelog
2626
import io.gitlab.arturbosch.detekt.Detekt
2727
import love.forte.plugin.suspendtrans.*
2828
import love.forte.plugin.suspendtrans.gradle.SuspendTransformGradleExtension
29+
import org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceSetSpec
30+
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
31+
import java.net.URI
32+
import java.time.Year
2933

3034
plugins {
3135
idea
32-
id("simbot.dokka-multi-module")
36+
id("org.jetbrains.dokka")
37+
// id("simbot.dokka-multi-module")
3338
id("com.github.gmazzo.buildconfig") version "5.5.1" apply false
3439
alias(libs.plugins.detekt)
3540
id("simbot.nexus-publish")
3641
alias(libs.plugins.suspendTransform) apply false
37-
// id("love.forte.plugin.suspend-transform") version "2.1.0-0.9.4" apply false
38-
3942

4043
// https://www.jetbrains.com/help/qodana/code-coverage.html
4144
// https://github.com/Kotlin/kotlinx-kover
4245
alias(libs.plugins.kotlinxKover)
4346

4447
alias(libs.plugins.kotlinxBinaryCompatibilityValidator)
48+
49+
4550
}
4651

4752
setupGroup(P.Simbot)
@@ -378,9 +383,6 @@ fun Project.configureSuspendTransform() {
378383
includeRuntime = false
379384
includeAnnotation = false
380385

381-
// love.forte.simbot.suspendrunner.SuspendMarker
382-
// targetMarker = ClassInfo("love.forte.simbot.suspendrunner", "SuspendMarker")
383-
384386
addJvmTransformers(
385387
// @JvmBlocking
386388
SuspendTransforms.jvmBlockingTransformer,
@@ -404,3 +406,146 @@ fun Project.configureSuspendTransform() {
404406
}
405407
}
406408
// endregion
409+
410+
// region Dokka
411+
subprojects {
412+
afterEvaluate {
413+
val p = this
414+
if (plugins.hasPlugin(libs.plugins.dokka.get().pluginId)) {
415+
dokka {
416+
dokkaSourceSets.configureEach {
417+
configModuleMdInclude(p)
418+
configSourceLink(p)
419+
configExternalDocumentations()
420+
}
421+
}
422+
rootProject.dependencies.dokka(p)
423+
}
424+
}
425+
}
426+
427+
fun DokkaSourceSetSpec.configModuleMdInclude(project: Project) {
428+
val moduleFile = project.file("Module.md")
429+
if (moduleFile.exists() && moduleFile.length() > 0) {
430+
includes.from("Module.md")
431+
}
432+
}
433+
434+
fun DokkaSourceSetSpec.configSourceLink(project: Project) {
435+
sourceLink {
436+
localDirectory.set(File(project.projectDir, "src"))
437+
val relativeTo = project.projectDir.relativeTo(rootProject.projectDir).toString()
438+
.replace('\\', '/')
439+
// remoteUrl.set(URI.create("${P.HOMEPAGE}/tree/v4-dev/$relativeTo/src/").toURL())
440+
remoteUrl.set(URI.create("${P.HOMEPAGE}/tree/v4-dev/$relativeTo/src"))
441+
remoteLineSuffix.set("#L")
442+
}
443+
}
444+
445+
fun DokkaSourceSetSpec.configExternalDocumentations() {
446+
fun externalDocumentation(name: String, docUrl: URI, suffix: String = "package-list") {
447+
externalDocumentationLinks.register(name) {
448+
url.set(docUrl)
449+
packageListUrl.set(docUrl.resolve(suffix))
450+
}
451+
}
452+
453+
// kotlin-coroutines doc
454+
externalDocumentation(
455+
"kotlinx.coroutines",
456+
URI.create("https://kotlinlang.org/api/kotlinx.coroutines/")
457+
)
458+
459+
// kotlin-serialization doc
460+
externalDocumentation(
461+
"kotlinx.serialization",
462+
URI.create("https://kotlinlang.org/api/kotlinx.serialization/")
463+
)
464+
465+
// ktor
466+
externalDocumentation(
467+
"ktor",
468+
URI.create("https://api.ktor.io/")
469+
)
470+
471+
// SLF4J
472+
externalDocumentation(
473+
"slf4j",
474+
URI.create("https://www.slf4j.org/apidocs/"),
475+
"element-list"
476+
)
477+
478+
// Spring Framework
479+
// TODO 准确的版本号?
480+
externalDocumentation(
481+
"spring-framework",
482+
URI.create("https://docs.spring.io/spring-framework/docs/current/javadoc-api/"),
483+
"element-list"
484+
)
485+
486+
// Spring Boot
487+
externalDocumentation(
488+
"spring-boot",
489+
URI.create("https://docs.spring.io/spring-boot/docs/${libs.versions.spring.boot.v3.get()}/api/"),
490+
"element-list"
491+
)
492+
}
493+
494+
dokka {
495+
moduleName = "Simple Robot"
496+
497+
dokkaPublications.all {
498+
if (isSimbotLocal()) {
499+
logger.info("Is 'SIMBOT_LOCAL', offline")
500+
offlineMode = true
501+
}
502+
}
503+
504+
dokkaSourceSets.configureEach {
505+
skipEmptyPackages = true
506+
suppressGeneratedFiles = false
507+
508+
documentedVisibilities(
509+
VisibilityModifier.Public,
510+
VisibilityModifier.Protected
511+
)
512+
513+
tasks.withType(JavaCompile::class.java).firstOrNull()
514+
?.targetCompatibility?.toInt().also {
515+
logger.info("project {} found jdkVersionValue: {}", project, it)
516+
}?.also {
517+
jdkVersion = it
518+
}
519+
520+
configModuleMdInclude(project)
521+
522+
perPackageOption {
523+
matchingRegex.set(".*internal.*") // will match all .internal packages and sub-packages
524+
suppress.set(true)
525+
}
526+
527+
configExternalDocumentations()
528+
}
529+
530+
pluginsConfiguration.html {
531+
customAssets.from(
532+
rootProject.file(".simbot/dokka-assets/logo-icon.svg"),
533+
rootProject.file(".simbot/dokka-assets/logo-icon-light.svg"),
534+
)
535+
536+
customStyleSheets.from(rootProject.file(".simbot/dokka-assets/css/kdoc-style.css"))
537+
538+
if (!isSimbotLocal()) {
539+
templatesDir = rootProject.file(".simbot/dokka-templates")
540+
}
541+
542+
footerMessage =
543+
"© 2021-${Year.now().value} <a href='https://github.com/simple-robot'>Simple Robot</a>. " +
544+
"All rights reserved."
545+
546+
separateInheritedMembers = true
547+
mergeImplicitExpectActualDeclarations = true
548+
homepageLink = P.HOMEPAGE
549+
}
550+
}
551+
// endregion

buildSrc/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024. ForteScarlet.
2+
* Copyright (c) 2024-2025. ForteScarlet.
33
*
44
* Project https://github.com/simple-robot/simpler-robot
55
@@ -40,7 +40,7 @@ dependencies {
4040
implementation(kotlin("power-assert", kotlinVersion))
4141
// compileOnly(kotlin("compiler", kotlinVersion))
4242
// compileOnly(kotlin("compiler-embeddable", kotlinVersion))
43-
implementation(libs.bundles.dokka)
43+
implementation(libs.dokka.plugin)
4444

4545
// see https://github.com/gradle-nexus/publish-plugin
4646
implementation(libs.gradleNexusPublishPlugin)

0 commit comments

Comments
 (0)