Skip to content

Disable Kotlin Playground for @sample rendering by defaultΒ #3041

@IgnatBeresnev

Description

@IgnatBeresnev

Problem

Embedded Kotlin Playground scripts are used to render the code referenced by the @sample KDoc tag. It works wonderfully for Kotlin's own standard and popular libraries, such as stdlib and kotlinx.coroutines, because they are included as dependencies by default.

However, you cannot simply add external dependencies to Kotlin Playground scripts - to do that, you have to fork the playground repo, add dependencies manually, and then host the playground yourself.

This means that in most cases the user code cannot be run by the playground, because external types are used in the samples, and they cannot be resolved by default.

Solution

Do not use Kotlin Playground to render @sample content by default. Instead, embed the code referenced in @sample as non-runnable code blocks. Support for Kotlin Playground runnable samples should be extracted into a separate plugin with its own settings.

Definition of Done

  • SamplesTransformer and relevant code should be extracted into a separate plugin.
  • Users should be able to provide their own kotlin-playground JS script (now hardcoded)
  • If the default script is used, it should be possible to specify a custom playground server URL (now hardcoded to play.kotlinlang.org in the JS script)
  • This plugin should replace default non-runnable code blocks with interactive and runnable Kotlin Playground samples.

As part of this issue, it's expected that some refactoring of DefaultSamplesTransformer will occur and that the tests for it will be revised (either new ones added or old ones checked)


Related: #1281

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn issue for a feature or an overall improvementformat: htmlAn issue/PR related to Dokka's default HTML output formathtml: backendAn issue/PR that affects the HTML format, but requires changes in common (content) Kotlin codetopic: frontend onboardingAn issue that could be used to onboard team members specializing in frontend development

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions