compile_book_file#

Import

from scenet import compile_book_file

Defined in

scenet.pipeline (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.pipeline.compile_book_file(path, *, library=None, metrics=None, dependencies=None)[source]#

Compile any supported document and its pages, choosing the frontend by extension.

Parameters:
  • path (Path) – A *.panel.yaml, *.scene.yaml or *.script file.

  • library (PuppetLibrary | None) – Characters to draw from. Defaults to the two shipped puppets.

  • metrics (FontMetrics | None) – Font to measure lettering against.

  • dependencies (set[Path] | None) – Optional set to populate with paths read during compilation, each resolved.

Return type:

Book

Returns:

Every panel, and the pages they are laid out on – none for a single panel or a comic script.

Raises:

Note

The frontend is chosen by extension alone: .script is a comic script, and any .yaml or .yml a panel or a scene by what it holds. This is what scenet build calls.

Example

>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> from scenet import compile_book_file
>>> with TemporaryDirectory() as folder:
...     path = Path(folder) / "page.scene.yaml"
...     _ = path.write_text(
...         "cast: {a: {reference: alice}}\n"
...         "panels: {one: {}, two: {}}\n"
...         "pages: [{tiers: [{panels: [one, two]}]}]",
...         encoding="utf-8",
...     )
...     read = set()
...     book = compile_book_file(path, dependencies=read)
>>> list(book.panels), len(book.pages)
(['one', 'two'], 1)
>>> path.resolve() in read
True

See also

compile_book, for text. compile_document, for its panels alone.

Added in version 0.13: The dependencies parameter.