Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow value rendering using renderers processor from API #183

Merged
merged 1 commit into from
Apr 6, 2021

Conversation

ileasile
Copy link
Contributor

@ileasile ileasile commented Apr 6, 2021

Fixes #182

Use it like this:

renderWithHost<C> { host, value: C -> notebook.renderersProcessor.renderValue(host, value_to_be_rendered) }

import org.jetbrains.kotlinx.jupyter.api.libraries.ExecutionHost

interface TypeRenderersProcessor {

fun renderResult(host: ExecutionHost, field: FieldValue): Any?

fun renderValue(host: ExecutionHost, value: Any?): Any?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear what this function does. Documentation would be nice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a problem here. Suppose the value is a container (List<Something>). The type of actual element renderer could not be resolved in the runtime due to type erasure. Won't it require KType?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding documentation: I've added it.
Regarding renderers: yes, due to type erasure KClass is the most we can get in runtime. It is how all the rendering mechanics works, it only uses KClass for getting type information. We could add Ktype argument here, but it would require breaking the renderers API, and it will actually be useless because it cannot be used for cells results rendering.

@ileasile ileasile force-pushed the allow_rendering_from_api branch from 24121e1 to 343c93d Compare April 6, 2021 16:56
@ileasile ileasile merged commit 4605d02 into master Apr 6, 2021
@ileasile ileasile deleted the allow_rendering_from_api branch April 6, 2021 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support rendering of an object dynamically inside CodeCell context
3 participants