-
Notifications
You must be signed in to change notification settings - Fork 471
Extract Kotlin Playground runnable samples into a separate plugin #4329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract Kotlin Playground runnable samples into a separate plugin #4329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new Dokka plugin called plugin-runnable-samples that makes @sample code blocks interactive and runnable using Kotlin Playground. The plugin extracts runnable samples functionality from the base plugin into a standalone, optional plugin.
Key changes:
- Creates new
plugin-runnable-samplesmodule with transformer, installer, and configuration components - Removes Kotlin Playground integration from the base plugin (DefaultSamplesTransformer, styles, scripts)
- Updates base plugin to use callback pattern for dark mode changes instead of directly managing Kotlin Playground
- Updates integration test expectations to reflect removed Kotlin Playground script references
Reviewed Changes
Copilot reviewed 156 out of 207 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| settings.gradle.kts | Adds new plugin-runnable-samples module to build |
| plugin-runnable-samples/* | New plugin with transformer, installer, configuration, tests, and resources |
| plugin-base/* | Removes runnable samples logic, styles, and scripts; refactors dark mode handling |
| dokka-subprojects/README.md | Documents new plugin in project structure |
| integration test files | Updates expected output to remove Kotlin Playground references |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private fun createSampleBody(imports: List<String>, body: String) = | ||
| // takeIf {} is needed so that joinToString's postfix is not added for empty lists, | ||
| // and trimMargin() then removes the first empty line | ||
| """ |${ |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on lines 101-102 is misaligned with the code. The opening triple-quote for the multi-line string starts on line 103, but the comment explaining trimMargin() appears on line 102, creating confusion about what the comment applies to. The comment should be moved above line 100 or reformatted to clearly explain the entire function's behavior.
|
(sorry, closed by accident)
|
vmishenev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍
I have some minor comments, but overall LGTM.
I would also add a unit test to check whether KotlinPlaygroundSamplesTransformer is applied.
.../main/kotlin/org.jetbrains.dokka.kotlinplaygroundsamples/KotlinPlaygroundSamplesInstaller.kt
Outdated
Show resolved
Hide resolved
dokka-subprojects/plugin-kotlin-playground-samples/api/plugin-kotlin-playground-samples.api
Outdated
Show resolved
Hide resolved
...projects/plugin-base/src/main/kotlin/org/jetbrains/dokka/base/renderers/html/HtmlRenderer.kt
Show resolved
Hide resolved
.../main/kotlin/org.jetbrains.dokka.kotlinplaygroundsamples/KotlinPlaygroundSamplesInstaller.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/org/jetbrains/dokka/kotlinPlaygroundSamples/KotlinPlaygroundSamplesInstaller.kt
Outdated
Show resolved
Hide resolved
...n/kotlin/org.jetbrains.dokka.kotlinplaygroundsamples/KotlinPlaygroundSamplesConfiguration.kt
Outdated
Show resolved
Hide resolved
|
@whyoleg Would you like to review this PR? Or will merging without your review be okay? |
Yeah, I would like to take a look! I will do it today/tomorrow. |
whyoleg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
We should probably create an issue to enable samples for kotlinx and stdlib?
@berezinant, could you please review the changes to .js/.css files (this and in plugin-kotlin-playground-samples module)?
Additionally, @berezinant, playground samples are now disabled by default. Should we still enable them in ui-showcase?
...src/main/kotlin/org/jetbrains/dokka/kotlinPlaygroundSamples/KotlinPlaygroundSamplesPlugin.kt
Outdated
Show resolved
Hide resolved
...src/main/kotlin/org.jetbrains.dokka.kotlinplaygroundsamples/KotlinPlaygroundSamplesPlugin.kt
Outdated
Show resolved
Hide resolved
8ed1cd6 to
24fc432
Compare
dokka-subprojects/plugin-kotlin-playground-samples/build.gradle.kts
Outdated
Show resolved
Hide resolved
|
@yuriioliinyk4 Could you resolve the merge conflicts and update the integration tests to merge this PR? |
…lesConfigurationTest
…ndServer to KotlinPlaygroundServer
…s registration to extension points
…KotlinPlaygroundSamplesTransformer to internal
d299198 to
286aeb8
Compare
286aeb8 to
ab1e065
Compare




Impl #3041