Jacob Wingate
12/11/2024, 12:16 PMtasks.dokkaHtml {
dokkaSourceSets.configureEach {
// Ensure this applies to the existing Dokka source sets
when (name) {
"main" -> {
sourceRoots.from(file("src/main/kotlin"))
}
"test" -> {
sourceRoots.from(file("src/test/kotlin"))
displayName.set("Test Documentation")
includes.from(file("src/test/kotlin"))
}
}
}
}
• Specifying the package:
tasks.dokkaHtml {
dokkaSourceSets {
named("main") {
sourceRoots.from(file("src/main/kotlin"))
displayName.set("Main Documentation")
}
named("test") {
sourceRoots.from(file("src/test/kotlin"))
displayName.set("Test Documentation")
platform.set(org.jetbrains.dokka.Platform.jvm) // Specify JVM platform
// Optional: Ensure packages are included
perPackageOption {
matchingRegex.set("com.timeCalculator.*")
suppress.set(false)
}
}
}
}
I have also tried to solve by treating the tests as separate modules and trying the Multi-Module approach as per the docs - to no avail. I have also had a good search through the thread here but didn't come across anything super apparent as a solution.
I apologise for any naivety as I am fairly new to Kotlin and programming in general.
I would be appreciative of any advice. CheersOleg Yukhnevich
12/11/2024, 12:34 PMI am having trouble getting Tests to populate in the dokkaHtml along with the classes and methods of the Main directory.First of all, I'm curious, why do you need to have tests available inside HTML API reference? As for the solution, probably you need to set
suppress
flag to false
. Dokka populates dokkaSourceSets
which are coming from KGP (Kotlin Gradle Plugin) and by default sets suppress=true
for test source sets.
So probably in your case you need to do just this:
tasks.dokkaHtml {
dokkaSourceSets {
named("test") {
suppress.set(false)
displayName.set("Test Documentation")
}
}
}
platform
and sourceRoots
will be configured automaticallyJacob Wingate
12/11/2024, 3:21 PM