-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDokkaConfigs.kt
More file actions
128 lines (110 loc) · 4.24 KB
/
Copy pathDokkaConfigs.kt
File metadata and controls
128 lines (110 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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)
}