Commit 7565f5f1 authored by Him188's avatar Him188

Update dokka task, prefer HTML format than GFM, for #333

parent 63d56006
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE")
import org.jetbrains.dokka.gradle.DokkaTask
import java.time.Duration
import kotlin.math.pow
......@@ -120,15 +121,15 @@ subprojects {
apply(plugin = "org.jetbrains.dokka")
this.tasks {
val dokka by getting(org.jetbrains.dokka.gradle.DokkaTask::class) {
val dokka by getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/dokka"
}
val dokkaMarkdown by creating(org.jetbrains.dokka.gradle.DokkaTask::class) {
val dokkaMarkdown by creating(DokkaTask::class) {
outputFormat = "markdown"
outputDirectory = "$buildDir/dokka-markdown"
}
val dokkaGfm by creating(org.jetbrains.dokka.gradle.DokkaTask::class) {
val dokkaGfm by creating(DokkaTask::class) {
outputFormat = "gfm"
outputDirectory = "$buildDir/dokka-gfm"
}
......@@ -137,17 +138,20 @@ subprojects {
val dokkaGitHubUpload by tasks.creating {
group = "mirai"
dependsOn(tasks.getByName("dokkaGfm"))
val dokkaTaskName = "dokka"
dependsOn(tasks.getByName(dokkaTaskName))
doFirst {
val baseDir = file("./build/dokka-gfm/${project.name}")
val baseDir = file("./build/$dokkaTaskName/${project.name}")
timeout.set(Duration.ofHours(6))
file("build/dokka-gfm/").walk()
file("build/$dokkaTaskName/").walk()
.filter { it.isFile }
.map { old ->
if (old.name == "index.md") File(old.parentFile, "README.md").also { new -> old.renameTo(new) }
else old
}
// optimize md
.forEach { file ->
if (file.endsWith(".md")) {
file.writeText(
......@@ -212,7 +216,7 @@ subprojects {
}
afterEvaluate {
tasks.filterIsInstance<org.jetbrains.dokka.gradle.DokkaTask>().forEach { task ->
tasks.filterIsInstance<DokkaTask>().forEach { task ->
with(task) {
configuration {
perPackageOption {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment