jupyter_ydoc
provides pycrdt-based data structures for various
documents used in the Jupyter ecosystem. Built-in documents include:
YBlob
: a generic immutable binary document.YUnicode
: a generic UTF8-encoded text document (YFile
is an alias toYUnicode
).YNotebook
: a Jupyter notebook document.
These documents are registered via an entry point under the "jupyter_ydoc"
group as "blob"
,
"unicode"
(or "file"
), and "notebook"
, respectively. You can access them as follows:
from jupyter_ydoc import ydocs
print(ydocs)
# {
# 'blob': <class 'jupyter_ydoc.yblob.YBlob'>,
# 'file': <class 'jupyter_ydoc.yfile.YFile'>,
# 'notebook': <class 'jupyter_ydoc.ynotebook.YNotebook'>,
# 'unicode': <class 'jupyter_ydoc.yunicode.YUnicode'>
# }
Which is just a shortcut to:
from importlib.metadata import entry_points
# for Python < 3.10, install importlib_metadata and do:
# from importlib_metadata import entry_points
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}
Or directly import them:
from jupyter_ydoc import YBlob, YUnicode, YNotebook
The "jupyter_ydoc"
entry point group can be populated with your own documents, e.g. by adding the
following to your package's pyproject.toml
:
[project.entry-points.jupyter_ydoc]
my_document = "my_package.my_file:MyDocumentClass"