Skip to content

Commit

Permalink
Merge pull request #512 from FWDekker/clean-dokka
Browse files Browse the repository at this point in the history
Clean Dokka output with Gradle task
  • Loading branch information
FWDekker authored Dec 9, 2023
2 parents 1c4ef72 + 59cf0ba commit aa0a143
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
run: |
rm -rf gh-pages/*
mv main/build/dokka/html/* gh-pages/
rm -rf gh-pages/older/**/.git
- name: Push new documentation
working-directory: gh-pages/
Expand Down
19 changes: 19 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
Expand Down Expand Up @@ -199,3 +200,21 @@ tasks {
}
}
}

// TODO: Remove this workaround for https://github.com/Kotlin/dokka/issues/3398 once it's fixed
abstract class DokkaHtmlPost : DefaultTask() {
private val buildDir = project.layout.buildDirectory

@TaskAction
fun strip() {
buildDir.dir("dokka/html/").get().asFile
.walk()
.filter { it.isDirectory && it.name.startsWith('.') }
.forEach { it.deleteRecursively() }

buildDir.dir("dokka/html/").get().asFileTree
.forEach { file -> file.writeText(file.readText().dropLastWhile { it == '\n' } + '\n') }
}
}
tasks.register<DokkaHtmlPost>("dokkaHtmlPost")
tasks.dokkaHtml { finalizedBy("dokkaHtmlPost") }

0 comments on commit aa0a143

Please sign in to comment.