Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/publish-kdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
gradle-version: ${{ env.GRADLE_VERSION }}
arguments: |
dokkaHtmlMultiModule
dokkaGenerate
--info
--warning-mode all
-x test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
with:
gradle-version: ${{ env.GRADLE_VERSION }}
arguments: |
dokkaHtmlMultiModule
dokkaGenerate
--info
--warning-mode all
-x test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
with:
gradle-version: ${{ env.GRADLE_VERSION }}
arguments: |
dokkaHtmlMultiModule
dokkaGenerate
-Porg.gradle.jvmargs="-Xmx4g -Xms4g -XX:MaxMetaspaceSize=2g -Dfile.encoding=UTF-8"
-Porg.gradle.daemon=false
--info
Expand Down
54 changes: 51 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import util.isCi

plugins {
idea
id("org.jetbrains.dokka")
`simbot-onebot-nexus-publish`
`simbot-onebot-dokka-multi-module`
`simbot-onebot-changelog-generator`

alias(libs.plugins.detekt)
alias(libs.plugins.kotlinxBinaryCompatibilityValidator)
alias(libs.plugins.suspendTransform) apply false
Expand Down Expand Up @@ -86,7 +85,7 @@ idea {
}
}

// detekt
//region detekt
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:${libs.versions.detekt.get()}")
}
Expand Down Expand Up @@ -125,6 +124,7 @@ tasks.withType<Detekt>().configureEach {
exclude("**/test/kotlin/")
exclude("**/test/java/")
}
//endregion

apiValidation {
ignoredPackages.add("*.internal.*")
Expand All @@ -151,3 +151,51 @@ apiValidation {

apiDumpDirectory = "api"
}

// region Dokka

// childProjects.values.forEach { childProject ->
// childProject.afterEvaluate {
// if (childProject.plugins.hasPlugin(libs.plugins.dokka.get().pluginId)) {
// dokka {
// configSourceSets(childProject)
// configHtmlCustoms(childProject)
// }
// rootProject.dependencies.dokka(childProject)
// }
// }
// }

subprojects {
afterEvaluate {
val p = this
if (plugins.hasPlugin(libs.plugins.dokka.get().pluginId)) {
dokka {
configSourceSets(p)
pluginsConfiguration.html {
configHtmlCustoms(project)
}
}
rootProject.dependencies.dokka(p)
}
}
}

dokka {
moduleName = "Simple Robot 组件 | OneBot"

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

configSourceSets(project)

pluginsConfiguration.html {
configHtmlCustoms(project)
}
}
// endregion

2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ val kotlinVersion: String = libs.versions.kotlin.get()
dependencies {
implementation(kotlin("gradle-plugin", kotlinVersion))
implementation(kotlin("serialization", kotlinVersion))
implementation(libs.bundles.dokka)
implementation(libs.dokka.plugin)

// see https://github.com/gradle-nexus/publish-plugin
implementation("io.github.gradle-nexus:publish-plugin:2.0.0")
Expand Down
128 changes: 128 additions & 0 deletions buildSrc/src/main/kotlin/DokkaConfigs.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import org.gradle.api.Project
import org.gradle.api.tasks.compile.JavaCompile
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceSetSpec
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
import org.jetbrains.dokka.gradle.engine.plugins.DokkaHtmlPluginParameters
import java.io.File
import java.net.URI
import java.time.Year

/*
* Copyright (c) 2025. ForteScarlet.
*
* This file is part of simbot-component-onebot.
*
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
* If not, see <https://www.gnu.org/licenses/>.
*/

fun DokkaExtension.configSourceSets(project: Project) {
dokkaSourceSets.configureEach {
skipEmptyPackages.set(true)
suppressGeneratedFiles.set(false)
documentedVisibilities(
VisibilityModifier.Public,
VisibilityModifier.Protected
)
project.tasks.withType(JavaCompile::class.java).firstOrNull()
?.targetCompatibility?.toInt().also {
logger.info("project {} found jdkVersionValue: {}", project, it)
}?.also {
jdkVersion.set(it)
}

configModuleMdInclude(project)

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

configSourceLink(project)

configExternalDocumentations()
}
}

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(project.rootProject.projectDir).toString()
.replace('\\', '/')
remoteUrl.set(URI.create("${P.ComponentOneBot.HOMEPAGE}/tree/dev/main/$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"
)
}

fun DokkaHtmlPluginParameters.configHtmlCustoms(project: Project) {
customAssets.from(
project.rootProject.file(".simbot/dokka-assets/logo-icon.svg"),
project.rootProject.file(".simbot/dokka-assets/logo-icon-light.svg"),
)

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

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

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

separateInheritedMembers.set(true)
mergeImplicitExpectActualDeclarations.set(true)
homepageLink.set(P.ComponentOneBot.HOMEPAGE)
}
126 changes: 63 additions & 63 deletions buildSrc/src/main/kotlin/simbot-onebot-dokka-multi-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
/*
* Copyright (c) 2024. ForteScarlet.
*
* This file is part of simbot-component-onebot.
*
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
* If not, see <https://www.gnu.org/licenses/>.
*/


import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import java.time.Year

plugins {
id("org.jetbrains.dokka")
}

repositories {
mavenCentral()
}

fun org.jetbrains.dokka.gradle.AbstractDokkaTask.configOutput(format: String) {
moduleName.set("Simple Robot 组件 | OneBot")
outputDirectory.set(rootProject.file("build/dokka/$format"))
}

@Suppress("MaxLineLength")
tasks.named<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("dokkaHtmlMultiModule") {
configOutput("html")
if (isSimbotLocal()) {
offlineMode.set(true)
}
// rootProject.file("README.md").takeIf { it.exists() }?.also {
// includes.from(it)
// }

pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
customAssets = listOf(
rootProject.file(".simbot/dokka-assets/logo-icon.svg"),
rootProject.file(".simbot/dokka-assets/logo-icon-light.svg"),
)
customStyleSheets = listOf(rootProject.file(".simbot/dokka-assets/css/kdoc-style.css"))
if (!isSimbotLocal()) {
templatesDir = rootProject.file(".simbot/dokka-templates")
}
val now = Year.now().value
val yearRange = if (now == 2024) "2024" else "2024-$now"
footerMessage = "© $yearRange <a href='https://github.com/simple-robot'>Simple Robot</a>. All rights reserved."
separateInheritedMembers = true
mergeImplicitExpectActualDeclarations = true
homepageLink = P.ComponentOneBot.HOMEPAGE
}
}

// /*
// * Copyright (c) 2024. ForteScarlet.
// *
// * This file is part of simbot-component-onebot.
// *
// * simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
// * of the GNU Lesser General Public License as published by the Free Software Foundation,
// * either version 3 of the License, or (at your option) any later version.
// *
// * simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// * See the GNU Lesser General Public License for more details.
// *
// * You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
// * If not, see <https://www.gnu.org/licenses/>.
// */
//
//
// import org.jetbrains.dokka.base.DokkaBase
// import org.jetbrains.dokka.base.DokkaBaseConfiguration
// import java.time.Year
//
// plugins {
// id("org.jetbrains.dokka")
// }
//
// repositories {
// mavenCentral()
// }
//
// fun org.jetbrains.dokka.gradle.AbstractDokkaTask.configOutput(format: String) {
// moduleName.set("Simple Robot 组件 | OneBot")
// outputDirectory.set(rootProject.file("build/dokka/$format"))
// }
//
// @Suppress("MaxLineLength")
// tasks.named<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("dokkaHtmlMultiModule") {
// configOutput("html")
// if (isSimbotLocal()) {
// offlineMode.set(true)
// }
// // rootProject.file("README.md").takeIf { it.exists() }?.also {
// // includes.from(it)
// // }
//
// pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
// customAssets = listOf(
// rootProject.file(".simbot/dokka-assets/logo-icon.svg"),
// rootProject.file(".simbot/dokka-assets/logo-icon-light.svg"),
// )
// customStyleSheets = listOf(rootProject.file(".simbot/dokka-assets/css/kdoc-style.css"))
// if (!isSimbotLocal()) {
// templatesDir = rootProject.file(".simbot/dokka-templates")
// }
// val now = Year.now().value
// val yearRange = if (now == 2024) "2024" else "2024-$now"
// footerMessage = "© $yearRange <a href='https://github.com/simple-robot'>Simple Robot</a>. All rights reserved."
// separateInheritedMembers = true
// mergeImplicitExpectActualDeclarations = true
// homepageLink = P.ComponentOneBot.HOMEPAGE
// }
// }
//
Loading