org.jetbrains.kotlinx.jupyter.api.libraries.LibraryDefinitionImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jupyter-api Show documentation
Show all versions of kotlin-jupyter-api Show documentation
API for libraries supporting Kotlin Jupyter notebooks
package org.jetbrains.kotlinx.jupyter.api.libraries
import org.jetbrains.kotlinx.jupyter.api.AfterCellExecutionCallback
import org.jetbrains.kotlinx.jupyter.api.ClassAnnotationHandler
import org.jetbrains.kotlinx.jupyter.api.CodePreprocessor
import org.jetbrains.kotlinx.jupyter.api.ExecutionCallback
import org.jetbrains.kotlinx.jupyter.api.FieldHandler
import org.jetbrains.kotlinx.jupyter.api.FileAnnotationHandler
import org.jetbrains.kotlinx.jupyter.api.InternalVariablesMarker
import org.jetbrains.kotlinx.jupyter.api.InterruptionCallback
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelVersion
import org.jetbrains.kotlinx.jupyter.api.RendererFieldHandler
import org.jetbrains.kotlinx.jupyter.api.TextRendererWithPriority
import org.jetbrains.kotlinx.jupyter.api.ThrowableRenderer
import org.jetbrains.kotlinx.jupyter.util.AcceptanceRule
/**
* Trivial implementation of [LibraryDefinition] - simple container.
*/
class LibraryDefinitionImpl private constructor() : LibraryDefinition {
override var options: Map = emptyMap()
override var description: String? = null
override var website: String? = null
override var dependencies: List = emptyList()
override var repositories: List = emptyList()
override var imports: List = emptyList()
override var init: List> = emptyList()
override var initCell: List> = emptyList()
override var afterCellExecution: List = emptyList()
override var shutdown: List> = emptyList()
override var renderers: List = emptyList()
override var textRenderers: List = emptyList()
override var throwableRenderers: List = emptyList()
override var converters: List = emptyList()
override var classAnnotations: List = emptyList()
override var fileAnnotations: List = emptyList()
override var resources: List = emptyList()
override var codePreprocessors: List = emptyList()
override var internalVariablesMarkers: List = emptyList()
override var minKernelVersion: KotlinKernelVersion? = null
override var originalDescriptorText: String? = null
override var integrationTypeNameRules: List> = emptyList()
override var interruptionCallbacks: List = emptyList()
override var colorSchemeChangedCallbacks: List = emptyList()
companion object {
internal fun build(buildAction: (LibraryDefinitionImpl) -> Unit): LibraryDefinition {
return LibraryDefinitionImpl().also(buildAction)
}
}
}
/**
* Builds an instance of [LibraryDefinition].
* Build action receives [LibraryDefinitionImpl] as an explicit argument
* because of problems with names clashing that may arise.
*/
fun libraryDefinition(buildAction: (LibraryDefinitionImpl) -> Unit): LibraryDefinition {
return LibraryDefinitionImpl.build(buildAction)
}