Skip to content

Commit

Permalink
Update Dokka to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ForteScarlet committed Feb 15, 2025
1 parent 27dc175 commit ae35ae4
Show file tree
Hide file tree
Showing 28 changed files with 335 additions and 275 deletions.
159 changes: 153 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,27 @@ import changelog.generateChangelog
import io.gitlab.arturbosch.detekt.Detekt
import love.forte.plugin.suspendtrans.*
import love.forte.plugin.suspendtrans.gradle.SuspendTransformGradleExtension
import org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceSetSpec
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
import java.net.URI
import java.time.Year

plugins {
idea
id("simbot.dokka-multi-module")
id("org.jetbrains.dokka")
// id("simbot.dokka-multi-module")
id("com.github.gmazzo.buildconfig") version "5.5.1" apply false
alias(libs.plugins.detekt)
id("simbot.nexus-publish")
alias(libs.plugins.suspendTransform) apply false
// id("love.forte.plugin.suspend-transform") version "2.1.0-0.9.4" apply false


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

alias(libs.plugins.kotlinxBinaryCompatibilityValidator)


}

setupGroup(P.Simbot)
Expand Down Expand Up @@ -378,9 +383,6 @@ fun Project.configureSuspendTransform() {
includeRuntime = false
includeAnnotation = false

// love.forte.simbot.suspendrunner.SuspendMarker
// targetMarker = ClassInfo("love.forte.simbot.suspendrunner", "SuspendMarker")

addJvmTransformers(
// @JvmBlocking
SuspendTransforms.jvmBlockingTransformer,
Expand All @@ -404,3 +406,148 @@ fun Project.configureSuspendTransform() {
}
}
// endregion

// region Dokka
subprojects {
afterEvaluate {
val p = this
if (plugins.hasPlugin(libs.plugins.dokka.get().pluginId)) {
dokka {
dokkaSourceSets.configureEach {
configModuleMdInclude(p)
configSourceLink(p)
configExternalDocumentations()
}
}
rootProject.dependencies.dokka(p)
}
}
}

fun DokkaSourceSetSpec.configModuleMdInclude(project: Project) {
val moduleFile = project.file("Module.md")
if (moduleFile.exists() && moduleFile.length() > 0) {
includes.from("Module.md")
}
}

fun DokkaSourceSetSpec.configSourceLink(project: Project) {
sourceLink {
localDirectory.set(File(project.projectDir, "src"))
val relativeTo = project.projectDir.relativeTo(rootProject.projectDir).toString()
.replace('\\', '/')
// remoteUrl.set(URI.create("${P.HOMEPAGE}/tree/v4-dev/$relativeTo/src/").toURL())
remoteUrl.set(URI.create("${P.HOMEPAGE}/tree/v4-dev/$relativeTo/src"))
remoteLineSuffix.set("#L")
}
}

fun DokkaSourceSetSpec.configExternalDocumentations() {
fun externalDocumentation(name: String, docUrl: URI, suffix: String = "package-list") {
externalDocumentationLinks.register(name) {
url.set(docUrl)
packageListUrl.set(docUrl.resolve(suffix))
}
}

// kotlin-coroutines doc
externalDocumentation(
"kotlinx.coroutines",
URI.create("https://kotlinlang.org/api/kotlinx.coroutines/")
)

// kotlin-serialization doc
externalDocumentation(
"kotlinx.serialization",
URI.create("https://kotlinlang.org/api/kotlinx.serialization/")
)

// ktor
externalDocumentation(
"ktor",
URI.create("https://api.ktor.io/")
)

// SLF4J
externalDocumentation(
"slf4j",
URI.create("https://www.slf4j.org/apidocs/"),
"element-list"
)

// Spring Framework
externalDocumentation(
"spring-framework",
URI.create("https://docs.spring.io/spring-framework/docs/current/javadoc-api/"),
"element-list"
)

// Spring Boot
externalDocumentation(
"spring-boot",
URI.create("https://docs.spring.io/spring-boot/docs/current/api/"),
"element-list"
)
}

dokka {
moduleName = "Simple Robot"

dokkaPublications.all {
if (isSimbotLocal()) {
logger.info("Is 'SIMBOT_LOCAL', offline")
offlineMode = true
}
}

dokkaSourceSets.configureEach {
skipEmptyPackages = true
suppressGeneratedFiles = false

documentedVisibilities(
VisibilityModifier.Public,
VisibilityModifier.Protected
)

tasks.withType(JavaCompile::class.java).firstOrNull()
?.targetCompatibility?.toInt().also {
logger.info("project {} found jdkVersionValue: {}", project, it)
}?.also {
jdkVersion = it
}

configModuleMdInclude(project)

perPackageOption {
matchingRegex.set(".*internal.*") // will match all .internal packages and sub-packages
suppress.set(true)
}

configExternalDocumentations()
}

pluginsConfiguration.html {
customAssets.from(
rootProject.file(".simbot/dokka-assets/logo-icon.svg"),
rootProject.file(".simbot/dokka-assets/logo-icon-light.svg"),
)

customStyleSheets.from(rootProject.file(".simbot/dokka-assets/css/kdoc-style.css"))

if (!isSimbotLocal()) {
templatesDir = rootProject.file(".simbot/dokka-templates")
}

footerMessage =
"© 2021-${Year.now().value} <a href='https://github.com/simple-robot'>Simple Robot</a>. " +
"All rights reserved."

separateInheritedMembers = true
mergeImplicitExpectActualDeclarations = true
homepageLink = P.HOMEPAGE
}

}


// endregion
33 changes: 1 addition & 32 deletions buildSrc/src/main/kotlin/simbot-jvm-maven-publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024. ForteScarlet.
* Copyright (c) 2022-2025. ForteScarlet.
*
* Project https://github.com/simple-robot/simpler-robot
* Email [email protected]
Expand Down Expand Up @@ -104,38 +104,7 @@ checkPublishConfigurable {
useInMemoryPgpKeys(keyId, secretKey, password)
sign(publishingExtension.publications)
}

// jvmConfigPublishing {
// project = P.findProjectDetailByGroup(p.group.toString()) ?: error("Unknown project group: ${p.group}")
// isSnapshot = project.version.toString().contains("SNAPSHOT", true)
//
// publicationName = "simbotDist"
//
// val jarSources by tasks.registering(Jar::class) {
// archiveClassifier.set("sources")
// from(sourceSets["main"].allSource)
// }
//
// val jarJavadoc by tasks.registering(Jar::class) {
// if (!(isSnapshot || isSnapshot() || isSimbotLocal())) {
// dependsOn(tasks.dokkaHtml)
// from(tasks.dokkaHtml.flatMap { it.outputDirectory })
// }
// archiveClassifier.set("javadoc")
// }
//
// artifact(jarSources)
// artifact(jarJavadoc)
//
// releasesRepository = ReleaseRepository
// snapshotRepository = SnapshotRepository
// gpg = Gpg.ofSystemPropOrNull()
//
//
// }
}
// show()
// }

fun MavenPublication.showMaven() {
val pom = pom
Expand Down
Loading

0 comments on commit ae35ae4

Please sign in to comment.