Skip to content

Sow

sereto.sow

render_sow_to_tex(project_path, config, version)

Render the SoW (top-level document) to TeX format.

Source code in sereto/sow.py
 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
@validate_call
def render_sow_to_tex(project_path: DirectoryPath, config: Config, version: ProjectVersion) -> str:
    """Render the SoW (top-level document) to TeX format."""
    # Construct path to SoW template
    template = project_path / "layouts/sow.tex.j2"
    if not template.is_file():
        raise SeretoPathError(f"template not found: '{template}'")

    # Render the Jinja template
    sow_generator = render_jinja2(
        templates=[
            project_path / "layouts/generated",
            project_path / "layouts",
            project_path / "includes",
            project_path,
        ],
        file=template,
        vars={
            "c": config.at_version(version=version),
            "config": config,
            "version": version,
            "project_path": project_path,
        },
    )

    return "".join(sow_generator)