parse_scene_document#

Import

from scenet import parse_scene_document

Defined in

scenet.frontends.yaml_front (source)

Install

pip install scenet

Since

0.10

Stability

Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how.

scenet.frontends.yaml_front.parse_scene_document(text, *, source=None)[source]#

Parse a scene and the pages it is laid out on.

page: and pages: are not panel defaults, unlike every other key beside panels:, so they are taken out before the defaults are applied.

Parameters:
  • text (str) – The document source.

  • source (Path | None) – Path it came from, used only to prefix error messages.

Return type:

SceneDocument

Returns:

The panels and the layout.

Raises:
  • PanelSyntaxError – A panel or the layout is malformed. A placement naming a panel that does not exist, or one placed twice, is rule page-layout.

  • CompositionError – An over: chain is unresolvable or cyclic.

Note

Composition is resolved and pages validated against the panels, but nothing is laid out.

Example

>>> from scenet import parse_scene_document
>>> document = parse_scene_document(
...     "cast: {a: {reference: alice}}\n"
...     "panels: {one: {}}\n"
...     "pages: [{tiers: [{panels: [one]}]}]"
... )
>>> list(document.panels), len(document.layout.pages)
(['one'], 1)

See also

compile_book, to compile it.