Skip to content

dizzy.generators.libconfig

dizzy.generators.libconfig

LibConfig generator — generates libconfig.yaml stub from a FeatureDefinition.

render_libconfig_stub(feat, default_runtime='python-uv')

Render libconfig.yaml stub content from a FeatureDefinition.

Source code in dizzy/src/dizzy/generators/libconfig.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def render_libconfig_stub(feat: FeatureDefinition, default_runtime: str = "python-uv") -> str:
    """Render libconfig.yaml stub content from a FeatureDefinition."""
    lines = [
        "# Dizzy library configuration — assign runtimes to each element",
        "# Supported runtimes: python-uv | rust-cargo | typescript-npm",
        "",
    ]
    for section, items in [
        ("procedures", feat.procedures or []),
        ("policies", feat.policies or []),
        ("queries", feat.queries or []),
        ("projections", feat.projections or []),
    ]:
        if items:
            lines.append(f"{section}:")
            for item in items:
                lines.append(f"  {item.name}:")
                lines.append(f"    runtimes: [{default_runtime}]")
            lines.append("")
    return "\n".join(lines)

write_libconfig_stub(feat, output_dir, default_runtime='python-uv')

Write libconfig.yaml to output_dir; skip if file already exists.

Source code in dizzy/src/dizzy/generators/libconfig.py
31
32
33
34
35
36
37
38
39
40
41
42
43
def write_libconfig_stub(
    feat: FeatureDefinition,
    output_dir: Path,
    default_runtime: str = "python-uv",
) -> None:
    """Write libconfig.yaml to output_dir; skip if file already exists."""
    dest = output_dir / "libconfig.yaml"
    if dest.exists():
        logger.debug("skipping %s — already exists", dest)
        return
    dest.parent.mkdir(parents=True, exist_ok=True)
    dest.write_text(render_libconfig_stub(feat, default_runtime=default_runtime))
    logger.debug("wrote %s", dest)