All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlinx.jupyter.ext.integration.Integration.kt Maven / Gradle / Ivy

There is a newer version: 0.12.0-333
Show 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"
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy