Skip to content

Commit

Permalink
fix the workaround for allowing nested module dirs (#85)
Browse files Browse the repository at this point in the history
cause: #60
related: Kotlin/dokka#2867
  • Loading branch information
aSemy authored Jun 2, 2023
1 parent a4d0987 commit 8d0cd5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import dev.adamko.dokkatoo.dokka.parameters.DokkaModuleDescriptionKxs
import dev.adamko.dokkatoo.dokka.parameters.builders.DokkaParametersBuilder
import dev.adamko.dokkatoo.internal.DokkaPluginParametersContainer
import dev.adamko.dokkatoo.internal.DokkatooInternalApi
import dev.adamko.dokkatoo.internal.adding
import dev.adamko.dokkatoo.workers.DokkaGeneratorWorker
import java.io.IOException
import javax.inject.Inject
Expand Down Expand Up @@ -158,10 +157,6 @@ constructor(
}

val dokkaModuleDescriptors = dokkaModuleDescriptors()
dokkaModuleDescriptors.forEach {
// workaround until https://github.com/Kotlin/dokka/pull/2867 is released
this.outputDirectory.dir(it.modulePath).get().asFile.mkdirs()
}

return DokkaParametersBuilder.build(
spec = generator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,26 @@ abstract class DokkaGeneratorWorker : WorkAction<DokkaGeneratorWorker.Parameters
override fun execute() {
val dokkaParameters = parameters.dokkaParameters.get()

// Dokka Generator doesn't clean up old files, so we need to manually clean the output directory
dokkaParameters.outputDir.deleteRecursively()
dokkaParameters.outputDir.mkdirs()
prepareOutputDir(dokkaParameters)

executeDokkaGenerator(
parameters.logFile.get().asFile,
dokkaParameters,
)
}

private fun prepareOutputDir(dokkaParameters: DokkaConfiguration) {
// Dokka Generator doesn't clean up old files, so we need to manually clean the output directory
dokkaParameters.outputDir.deleteRecursively()
dokkaParameters.outputDir.mkdirs()

// workaround until https://github.com/Kotlin/dokka/pull/2867 is released
dokkaParameters.modules.forEach { module ->
val moduleDir = dokkaParameters.outputDir.resolve(module.relativePathToOutputDirectory)
moduleDir.mkdirs()
}
}

private fun executeDokkaGenerator(
logFile: File,
dokkaParameters: DokkaConfiguration
Expand Down

0 comments on commit 8d0cd5e

Please sign in to comment.