builder¶
- class typy.builder.DocumentBuilder(verbose=False)[source]¶
Bases:
object- Parameters:
verbose (bool)
- add_typ_template(typ_path, data=None)[source]¶
Add a raw Typst .typ template file with optional JSON-serialisable data dict.
- Parameters:
typ_path (Path) – Path to the .typ Typst template file to render.
data (dict | None) – Optional dictionary of template variables. When provided, the data is encoded and written to
typy_data.typin the build directory so the template can import it.
- Returns:
self – enables method chaining.
- copy_assets_from(source_dir)[source]¶
Copy files from source_dir into the build temp dir.
This makes relative paths (e.g.
assets/image.png) in the document resolvable during Typst compilation, which otherwise runs in an isolated temporary directory.Files named
main.typ,typy_data.typ, andtypy.typare intentionally excluded so the generated build files are not overwritten.- Parameters:
source_dir (Path) – Directory whose contents are copied to the build dir.
- Returns:
self – enables method chaining.
- Return type: