org.jetbrains.kotlinx.jupyter.ext.integration.Integration.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jupyter-lib-ext Show documentation
Show all versions of kotlin-jupyter-lib-ext Show documentation
Extended functionality for Kotlin kernel
The newest version!
package org.jetbrains.kotlinx.jupyter.ext.integration
import org.jetbrains.kotlinx.jupyter.api.annotations.JupyterLibrary
import org.jetbrains.kotlinx.jupyter.api.graphs.GraphNode
import org.jetbrains.kotlinx.jupyter.api.graphs.GraphNodes
import org.jetbrains.kotlinx.jupyter.api.libraries.JupyterIntegration
import org.jetbrains.kotlinx.jupyter.ext.graph.structure.Graph
import org.jetbrains.kotlinx.jupyter.ext.graph.structure.MultiGraph
import org.jetbrains.kotlinx.jupyter.ext.graph.visualization.render
import org.jetbrains.kotlinx.jupyter.ext.graph.wrappers.KClassNode
import java.io.File
@JupyterLibrary
class Integration : JupyterIntegration() {
override fun Builder.onLoaded() {
import("org.jetbrains.kotlinx.jupyter.ext.*")
importPackage>()
importPackage()
import()
render> {
it.render()
}
renderWithDefinedRenderers> { Graph.of(it) }
renderWithDefinedRenderers> { Graph.of(it.nodes) }
}
private inline fun Builder.renderWithDefinedRenderers(crossinline getValue: (T) -> Any?) {
renderWithHost { host, value ->
notebook.renderersProcessor.renderValue(host, getValue(value)) ?: "null"
}
}
}