Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dokka to 2.0.0-Beta #985

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build docs with Gradle
run: ./gradlew --stacktrace --info dokkaHtmlMultiModule
run: ./gradlew --stacktrace --info :dokkaGeneratePublicationHtml
- name: Deploy docs to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/dokka/htmlMultiModule
folder: build/dokka/html
branch: gh-pages
git-config-name: GitHub Actions
git-config-email: [email protected]
Expand Down
11 changes: 10 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
org.jetbrains.dokka // for dokkaHtmlMultiModule task
org.jetbrains.dokka // for dokkaGeneratePublicationHtml task
}

repositories {
Expand All @@ -8,3 +8,12 @@ repositories {

group = Library.group
version = libraryVersion

dependencies {
dokka(projects.common)
dokka(projects.core)
dokka(projects.coreVoice)
dokka(projects.gateway)
dokka(projects.rest)
dokka(projects.voice)
}
39 changes: 27 additions & 12 deletions buildSrc/src/main/kotlin/Documentation.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import org.gradle.api.Project
import org.gradle.kotlin.dsl.assign
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import java.net.URI
import org.gradle.kotlin.dsl.invoke
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.dokka.gradle.workers.ProcessIsolation

fun AbstractDokkaLeafTask.applyKordDokkaOptions() {
internal fun DokkaExtension.applyKordDokkaOptions(project: Project) {

// Dokka runs out of memory with the default maxHeapSize when ProcessIsolation is used
(dokkaGeneratorIsolation.get() as? ProcessIsolation)?.maxHeapSize = "1g"

moduleName = "kord-${project.name}"

failOnWarning = true
dokkaPublications.configureEach {
failOnWarning = true
}

dokkaSourceSets.configureEach {

Expand All @@ -16,17 +23,25 @@ fun AbstractDokkaLeafTask.applyKordDokkaOptions() {

sourceLink {
localDirectory = project.projectDir
remoteUrl = URI("https://github.com/kordlib/kord/blob/${project.commitHash}/${project.name}").toURL()
remoteUrl("https://github.com/kordlib/kord/blob/${project.commitHash}/${project.name}")
remoteLineSuffix = "#L"
}

externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/")
externalDocumentationLink("https://kotlinlang.org/api/kotlinx.serialization/")
externalDocumentationLink(
url = "https://kotlinlang.org/api/kotlinx-datetime/",
packageListUrl = "https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/package-list",
)
externalDocumentationLink("https://api.ktor.io/")
externalDocumentationLinks {
register("kotlinx.coroutines") {
url("https://kotlinlang.org/api/kotlinx.coroutines/")
}
register("kotlinx.serialization") {
url("https://kotlinlang.org/api/kotlinx.serialization/")
}
register("kotlinx-datetime") {
url("https://kotlinlang.org/api/kotlinx-datetime/")
packageListUrl("https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/package-list")
}
register("Ktor") {
url("https://api.ktor.io/")
}
}

// don't list `TweetNaclFast` in docs
perPackageOption {
Expand Down
10 changes: 4 additions & 6 deletions buildSrc/src/main/kotlin/kord-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask

plugins {
org.jetbrains.kotlin.jvm
org.jetbrains.kotlin.plugin.serialization
Expand Down Expand Up @@ -34,15 +32,15 @@ kotlin {
}
}

dokka {
applyKordDokkaOptions(project)
}

tasks {
withType<Test>().configureEach {
useJUnitPlatform()
}

withType<AbstractDokkaLeafTask>().configureEach {
applyKordDokkaOptions()
}

withType<JavaCompile>().configureEach {
options.release = KORD_JVM_TARGET
}
Expand Down
19 changes: 12 additions & 7 deletions buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest

Expand Down Expand Up @@ -71,6 +70,10 @@ kotlin {
}
}

dokka {
applyKordDokkaOptions(project)
}

tasks {
withType<Test>().configureEach {
useJUnitPlatform()
Expand All @@ -80,7 +83,14 @@ tasks {
environment("PROJECT_ROOT", rootProject.projectDir.absolutePath)
}

for (task in listOf("compileKotlinJvm", "compileKotlinJs", "jvmSourcesJar", "jsSourcesJar")) {
for (task in listOf(
"compileKotlinJvm",
"compileKotlinJs",
"jvmSourcesJar",
"jsSourcesJar",
"dokkaGenerateModuleHtml",
"dokkaGeneratePublicationHtml",
)) {
named(task) {
dependsOn("kspCommonMainKotlinMetadata")
}
Expand All @@ -91,9 +101,4 @@ tasks {
dependsOn("kspCommonMainKotlinMetadata")
}
}

withType<AbstractDokkaLeafTask>().configureEach {
applyKordDokkaOptions()
dependsOn("kspCommonMainKotlinMetadata")
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/kord-publishing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fun MavenPublication.registerDokkaJar() =
tasks.register<Jar>("${name}DokkaJar") {
archiveClassifier = "javadoc"
destinationDirectory = destinationDirectory.get().dir(name)
from(tasks.named("dokkaHtml"))
from(tasks.named("dokkaGeneratePublicationHtml"))
}

publishing {
Expand Down
6 changes: 0 additions & 6 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,3 @@ apiValidation {
// https://github.com/Kotlin/binary-compatibility-validator/issues/88
ignoredProjects += "live-tests"
}

tasks {
dokkaHtmlMultiModule {
enabled = false
}
}
9 changes: 7 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# the version that is planned to be released next, snapshot versions for the 'main' branch are based on this
nextPlannedVersion=0.15.0

#dokka will run out of memory with the default meta space
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1024m
org.gradle.parallel=true
org.gradle.warning.mode=all
org.gradle.kotlin.dsl.allWarningsAsErrors=true
kotlin.code.style=official

# the Kotlin daemon runs out of memory with the default maximum heap size
kotlin.daemon.jvmargs=-Xmx2g

# https://kotlinlang.org/docs/dokka-migration.html#set-the-opt-in-flag
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

# https://github.com/Kotlin/kotlinx-atomicfu/issues/448
# https://youtrack.jetbrains.com/issue/KT-64109#focus=Comments-27-10064206.0-0
kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mockk = "1.13.12" # https://github.com/mockk/mockk
kbson = "0.4.0" # https://github.com/mongodb/kbson

# plugins
dokka = "1.9.20" # https://github.com/Kotlin/dokka
dokka = "2.0.0-Beta" # https://github.com/Kotlin/dokka
kotlinx-atomicfu = "0.25.0" # https://github.com/Kotlin/kotlinx-atomicfu
binary-compatibility-validator = "0.16.3" # https://github.com/Kotlin/binary-compatibility-validator
buildconfig = "5.4.0" # https://github.com/gmazzo/gradle-buildconfig-plugin
Expand Down Expand Up @@ -85,7 +85,7 @@ slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
kbson = { module = "org.mongodb.kbson:kbson", version.ref = "kbson" }

# actually plugins, not libraries, but used is 'buildSrc/build.gradle.kts' as implementation dependencies:
# https://docs.gradle.org/current/userguide/custom_plugins.html#applying_external_plugins_in_precompiled_script_plugins
# https://docs.gradle.org/current/userguide/implementing_gradle_plugins_precompiled.html#sec:applying_external_plugins
kotlin-jvm-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
Expand Down
4 changes: 1 addition & 3 deletions ksp-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask

plugins {
`kord-internal-multiplatform-module`

Expand All @@ -10,7 +8,7 @@ plugins {
`kord-publishing`
}

tasks.withType<AbstractDokkaLeafTask>().configureEach {
dokka {
dokkaSourceSets.configureEach {
suppress = true
}
Expand Down