How do you embed runnable sample code in Dokka generated documentation

I'm trying to add sample code to my API Reference.

I followed the pattern highlighted here https://androidessence.com/contributing-to-kotlin Was able to create my sample project and all the code runs, duplicating the _sampleUtils that the the kotlin stdlib source uses.

I configured my module to include the sample in the dokka configuration.

tasks.dokkaHtml {
    dokkaSourceSets.configureEach {
        samples.from("$projectDir/../module-samples/test/samples/SampleFile.kt")
    }
}

The sample correctly loads into and is displayed in the documentation for the function with a run button.

When I hit run though, it just comes back with Unresolved reference for all the symbols in my library. It also could not find assertPrint method from the _samplesUtils.kt file.

I don't see any other settings in the Dokka configuration for samples to make it include jar files for the library being documented.



Read more here: https://stackoverflow.com/questions/64395326/how-do-you-embed-runnable-sample-code-in-dokka-generated-documentation

Content Attribution

This content was originally published by Michael Krussel at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: