Skip to content

Conversation

@yuriioliinyk4
Copy link

Impl #3041

@vmishenev vmishenev linked an issue Nov 1, 2025 that may be closed by this pull request
Copy link

Copilot AI left a 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-samples module 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.

Comment on lines 100 to 103
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
""" |${
Copy link

Copilot AI Nov 3, 2025

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.

Copilot uses AI. Check for mistakes.
@whyoleg whyoleg closed this Nov 3, 2025
@whyoleg whyoleg reopened this Nov 3, 2025
@whyoleg
Copy link
Collaborator

whyoleg commented Nov 3, 2025

(sorry, closed by accident)
I haven't reviewed the PR in detail yet, but I do have several high-level suggestions:

  1. What do you think about renaming the plugin to kotlin-playground-plugin or kotlin-playground-samples-plugin? It's mostly about the fact that runnable is too generic, and might imply that this plugin will somehow run samples, such as tests, when it's really only about running them on the playground.
  2. We should consider providing type-safe accessors for the new Dokka plugin in the Dokka Gradle plugin (as for the versioning plugin), as samples are needed in the stdlib and all kotlinx libraries, and so just copying the configuration from the Configuration example using Dokka Gradle Plugin v2 section is not really feasible.
  3. It would be really nice to check how those changes will work on one of the kotlinx libraries before merging the PR. For me, kotlinx.io has the simplest setup for testing changes.

@yuriioliinyk4
Copy link
Author

What do you think about renaming the plugin to kotlin-playground-plugin or kotlin-playground-samples-plugin?

I have renamed plugin to kotlin-playground-samples-plugin.

We should consider providing type-safe accessors for the new Dokka plugin in the Dokka Gradle plugin

I agree, I will implement this.

It would be really nice to check how those changes will work on one of the kotlinx libraries before merging the PR.

I have checked it, seems like everything is fine, examples below

2.1.0(currently):
telegram-cloud-photo-size-2-5211158162285727239-y

this PR, without plugin(by default):
telegram-cloud-photo-size-2-5211158162285727236-y

this PR with applied kotlin-playground-samples-plugin(looks exactly the same as in 2.1.0):
telegram-cloud-photo-size-2-5211158162285727250-y

The only thing I noticed is that the new samples without the plugin are too close to each other(see screenshot below). As for me, it’s easy to mistake them for a single sample. I’d suggest adding a bit more spacing between them. I can create an issue for this after merging this PR. What do you think?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable Kotlin Playground for @sample rendering by default

2 participants