Skip to content

Commit 93c8d0f

Browse files
committed
Move JupyterCellRenderer
1 parent fda36bb commit 93c8d0f

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CellRenderer.kt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
package org.jetbrains.kotlinx.dataframe.jupyter
22

33
import org.jetbrains.kotlinx.dataframe.io.DisplayConfiguration
4-
import org.jetbrains.kotlinx.dataframe.io.internallyRenderable
54
import org.jetbrains.kotlinx.dataframe.io.renderValueForHtml
65
import org.jetbrains.kotlinx.dataframe.io.tooltipLimit
7-
import org.jetbrains.kotlinx.jupyter.api.MimeTypedResult
8-
import org.jetbrains.kotlinx.jupyter.api.Notebook
9-
import org.jetbrains.kotlinx.jupyter.api.Renderable
10-
import org.jetbrains.kotlinx.jupyter.api.libraries.ExecutionHost
116

127
public data class RenderedContent(
138
val truncatedContent: String,
@@ -69,22 +64,3 @@ public object DefaultCellRenderer : CellRenderer {
6964
}
7065
}
7166

72-
internal class JupyterCellRenderer(
73-
private val notebook: Notebook,
74-
private val host: ExecutionHost,
75-
) : ChainedCellRenderer(DefaultCellRenderer) {
76-
override fun maybeContent(value: Any?, configuration: DisplayConfiguration): RenderedContent? {
77-
val renderersProcessor = notebook.renderersProcessor
78-
if (internallyRenderable(value)) return null
79-
val renderedVal = renderersProcessor.renderValue(host, value)
80-
val finalVal = if (renderedVal is Renderable) renderedVal.render(notebook) else renderedVal
81-
if (finalVal is MimeTypedResult && "text/html" in finalVal) return RenderedContent.media(
82-
finalVal["text/html"] ?: ""
83-
)
84-
return renderValueForHtml(finalVal, configuration.cellContentLimit, configuration.decimalFormat)
85-
}
86-
87-
override fun maybeTooltip(value: Any?, configuration: DisplayConfiguration): String? {
88-
return null
89-
}
90-
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.jetbrains.kotlinx.dataframe.jupyter
2+
3+
import org.jetbrains.kotlinx.dataframe.io.DisplayConfiguration
4+
import org.jetbrains.kotlinx.dataframe.io.internallyRenderable
5+
import org.jetbrains.kotlinx.dataframe.io.renderValueForHtml
6+
import org.jetbrains.kotlinx.jupyter.api.MimeTypedResult
7+
import org.jetbrains.kotlinx.jupyter.api.Notebook
8+
import org.jetbrains.kotlinx.jupyter.api.Renderable
9+
import org.jetbrains.kotlinx.jupyter.api.libraries.ExecutionHost
10+
11+
internal class JupyterCellRenderer(
12+
private val notebook: Notebook,
13+
private val host: ExecutionHost,
14+
) : ChainedCellRenderer(DefaultCellRenderer) {
15+
override fun maybeContent(value: Any?, configuration: DisplayConfiguration): RenderedContent? {
16+
val renderersProcessor = notebook.renderersProcessor
17+
if (internallyRenderable(value)) return null
18+
val renderedVal = renderersProcessor.renderValue(host, value)
19+
val finalVal = if (renderedVal is Renderable) renderedVal.render(notebook) else renderedVal
20+
if (finalVal is MimeTypedResult && "text/html" in finalVal) return RenderedContent.media(
21+
finalVal["text/html"] ?: ""
22+
)
23+
return renderValueForHtml(finalVal, configuration.cellContentLimit, configuration.decimalFormat)
24+
}
25+
26+
override fun maybeTooltip(value: Any?, configuration: DisplayConfiguration): String? {
27+
return null
28+
}
29+
}

0 commit comments

Comments
 (0)