Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean Dokka output with Gradle task #512

Merged
merged 1 commit into from
Dec 9, 2023
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
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") }