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") @file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE")
import org.jetbrains.dokka.gradle.DokkaTask
import java.time.Duration import java.time.Duration
import kotlin.math.pow import kotlin.math.pow
...@@ -120,15 +121,15 @@ subprojects { ...@@ -120,15 +121,15 @@ subprojects {
apply(plugin = "org.jetbrains.dokka") apply(plugin = "org.jetbrains.dokka")
this.tasks { this.tasks {
val dokka by getting(org.jetbrains.dokka.gradle.DokkaTask::class) { val dokka by getting(DokkaTask::class) {
outputFormat = "html" outputFormat = "html"
outputDirectory = "$buildDir/dokka" outputDirectory = "$buildDir/dokka"
} }
val dokkaMarkdown by creating(org.jetbrains.dokka.gradle.DokkaTask::class) { val dokkaMarkdown by creating(DokkaTask::class) {
outputFormat = "markdown" outputFormat = "markdown"
outputDirectory = "$buildDir/dokka-markdown" outputDirectory = "$buildDir/dokka-markdown"
} }
val dokkaGfm by creating(org.jetbrains.dokka.gradle.DokkaTask::class) { val dokkaGfm by creating(DokkaTask::class) {
outputFormat = "gfm" outputFormat = "gfm"
outputDirectory = "$buildDir/dokka-gfm" outputDirectory = "$buildDir/dokka-gfm"
} }
...@@ -137,17 +138,20 @@ subprojects { ...@@ -137,17 +138,20 @@ subprojects {
val dokkaGitHubUpload by tasks.creating { val dokkaGitHubUpload by tasks.creating {
group = "mirai" group = "mirai"
dependsOn(tasks.getByName("dokkaGfm")) val dokkaTaskName = "dokka"
dependsOn(tasks.getByName(dokkaTaskName))
doFirst { doFirst {
val baseDir = file("./build/dokka-gfm/${project.name}") val baseDir = file("./build/$dokkaTaskName/${project.name}")
timeout.set(Duration.ofHours(6)) timeout.set(Duration.ofHours(6))
file("build/dokka-gfm/").walk() file("build/$dokkaTaskName/").walk()
.filter { it.isFile } .filter { it.isFile }
.map { old -> .map { old ->
if (old.name == "index.md") File(old.parentFile, "README.md").also { new -> old.renameTo(new) } if (old.name == "index.md") File(old.parentFile, "README.md").also { new -> old.renameTo(new) }
else old else old
} }
// optimize md
.forEach { file -> .forEach { file ->
if (file.endsWith(".md")) { if (file.endsWith(".md")) {
file.writeText( file.writeText(
...@@ -212,7 +216,7 @@ subprojects { ...@@ -212,7 +216,7 @@ subprojects {
} }
afterEvaluate { afterEvaluate {
tasks.filterIsInstance<org.jetbrains.dokka.gradle.DokkaTask>().forEach { task -> tasks.filterIsInstance<DokkaTask>().forEach { task ->
with(task) { with(task) {
configuration { configuration {
perPackageOption { 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