The key resource for the plumbing is in the Integrating your objects with IPython section of the docs.
Here’s an example:
class Foo:
def __init__(self, x, y):
self.x = x
self.y = y
def _repr_mimebundle_(self, **kwargs):
return {
"text/plain": f"x={self.x}",
"text/latex": f"$x = {self.x}\\\\y = {self.y}$"
}
foo = Foo(1, 2)
foo
yields:
