Hi, I am working on library that is using Jetpack Compose. Is there any way on how to display components using @sample annotation in KDoc? I am getting an error “Unresolved reference ‘androidx’” in interactive preview
z
Zach Klippenstein (he/him) [MOD]
08/19/2025, 8:31 PM
I'm not quite sure what you're asking:
• Are you trying to view the samples from compose APIs?
• Are you trying to add sample code to your own kdocs?
• Are you trying to include the renderings of your composables in your kdocs?
v
Vojtech Hrdina
08/19/2025, 10:08 PM
I am trying to include sample code using @sample annotation and display composable preview in interactive mode. I attached the screenshot with example. I noticed that playground at https://play.kotlinlang.org/ can display composables.
I am using dokka 2.0 and
Hey!
It's not really possible to do it like this, unfortunately 😞
1. Kotlin Playground doesn't allow external dependencies, so it's possible to run only code that uses out-of-the-box available dependencies - in the case of compose, it's probably limited to some material-related dependencies
2. Dokka currently embeds Kotlin Playground in JVM mode only
Still, you might be interested in https://github.com/Kotlin/Storytale. I'm not sure how hard it is to set up 😞
v
Vojtech Hrdina
08/20/2025, 10:10 PM
Thank you.
1. I can see that there is an option to run my own instance and I can modify Dokka to point to this instance. But I don’t think it would be good solution for long term running project
Storytale looks great. Unfortunately it support only multiplatform projects and it is not compatible with kotlin 2+.. Just found version