
org.jetbrains.kotlinx.jupyter.ext.integration.Integration.kt Maven / Gradle / Ivy
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"
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy