extensible metadata in the notebook formatยค
this document is the minimum schema to make metadata extensible. it makes clearer distinctions between the notebook, cell and display metadata.
new metadata schema are combined using the allOf
key that references schema from other places.
%reload_ext pidgy
from midgy.utils import *; import tomli
the extended schema is written below in toml.
schema = strip_fence | tomli.loads | \
```toml
description = "extensible metadata for the notebook schema."
["$defs".notebook-meta]
"$anchor" = "notebook-meta"
allOf = [
{"$ref" = "kernelspec.json"}
]
["$defs".code-meta]
"$anchor" = "code-meta"
allOf = [
{"$ref" = "#slides"}
]
["$defs".display-meta]
"$anchor" = "display-meta"
allOf = [
{"$ref" = "#images"},
{"$ref" = "#json"}
]
["$defs".slides]
"$anchor" = "slides"
properties.slides.enum = ["slide", "subslide", "fragment"]
[properties]
metadata."$ref" = "#notebook-meta"
[properties.cells.items.properties.metadata]
"$ref" = "#cell-meta"
[properties.cells.items.properties.outputs.items.properties.metadata]
outputs.items.properties.metadata."$ref" = "#display-meta"
```
schema = strip_fence | tomli.loads | \
toml
description = "extensible metadata for the notebook schema."
["$defs".notebook-meta]
"$anchor" = "notebook-meta"
allOf = [
{"$ref" = "kernelspec.json"}
]
["$defs".code-meta]
"$anchor" = "code-meta"
allOf = [
{"$ref" = "#slides"}
]
["$defs".display-meta]
"$anchor" = "display-meta"
allOf = [
{"$ref" = "#images"},
{"$ref" = "#json"}
]
["$defs".slides]
"$anchor" = "slides"
properties.slides.enum = ["slide", "subslide", "fragment"]
[properties]
metadata."$ref" = "#notebook-meta"
[properties.cells.items.properties.metadata]
"$ref" = "#cell-meta"
[properties.cells.items.properties.outputs.items.properties.metadata]
outputs.items.properties.metadata."$ref" = "#display-meta"
it is shown in json below.
pprint.pprint(schema)
JSON(schema, expanded=False)
pprint.pprint(schema)
JSON(schema, expanded=False)