How do I include (tested, non-stale) code samples into Dokka package documentation?
More specifically, assuming that I have this configuration in my build.gradle.kts
:
withType<DokkaTask> {
outputFormat = "html"
outputDirectory = "$buildDir/documentation"
includes = listOf("packageDocumentation.md")
samples = listOf("$rootDir/src/test/kotlin/some/project/TheSamples.kt")
}
And then some test code:
package some.project
import org.junit.jupiter.api.Test
class TheSamples {
@Test
fun helloWorldSample() {
println("hello, world")
}
}
and also a package documentation Markdown file:
# Package some.project
This is the documentation for some package.
@sample some.project.TheSamples#helloWorldSample
, how do I include the println(...)
-part into the documentation? Is it supported at all in the current version of Dokka?
Exchanging #
for .
or replacing @sample
by @includeFunction
didn't do anything.
Furthermore:
- Here is a related question, left unanswered for almost two years.
- Here is some discussion from 2012, which by now consists almost entirely of dead links.