File: README.md

package info (click to toggle)
jupyterlab 4.0.11%2Bds1%2B~cs11.25.27-7
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 43,496 kB
  • sloc: javascript: 18,395; python: 8,932; sh: 399; makefile: 95; perl: 33; xml: 1
file content (48 lines) | stat: -rw-r--r-- 1,782 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[![Build Status](https://github.com/jupyter-server/jupyter_ydoc/workflows/Tests/badge.svg)](https://github.com/jupyter-server/jupyter_ydoc/actions)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![PyPI](https://img.shields.io/pypi/v/jupyter-ydoc)](https://pypi.org/project/jupyter-ydoc/)
[![npm (scoped)](https://img.shields.io/npm/v/@jupyter/ydoc)](https://www.npmjs.com/package/@jupyter/ydoc)

# jupyter_ydoc

`jupyter_ydoc` provides [Ypy](https://github.com/y-crdt/ypy)-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 to `YUnicode`).
- `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:

```py
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:

```py
import pkg_resources

ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
```

Or directly import them:
```py
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"
```