Skip to content

Declaration-to-output gallery

Read generated results here; run examples from the catalog. These code blocks are output to inspect, not declarations to copy into your generator. Start with the first tutorial if you want the input-to-output walkthrough.

Every block below is extracted from canonical output generated by the tutorial. The tutorial executes the AST and asserts independent behavior before the canonical wrapper writes a snapshot. Formatting alone is not an oracle.

Two owners and repeated field names

The same FieldName = x is owned by Point and Size. Composite numeric build indices and owner filters keep their parameter/store contributions separate. Reversed field insertion still yields FieldOrder order:

Source authority: tests/data/goldens/materialized/documentation_classes/extended_model.py.

class Point:
    __slots__ = ('x', 'y')
    pass

    def __init__(self, x, y):
        pass
        pass
        self.x = x
        self.y = y

class Size:
    __slots__ = ('x',)
    pass

    def __init__(self, x):
        pass
        pass
        self.x = x

Zero fields

Explicit empty parameter/statement contributions close mandatory holes. Zero fields still produces a valid class and constructor:

Source authority: tests/data/goldens/materialized/documentation_classes/empty_model.py.

class Point:
    __slots__ = ()
    pass

    def __init__(self):
        pass
        pass

Disabled initialization

An empty-source method selection suppresses init; a separate class pass fills the required class body surface:

Source authority: tests/data/goldens/materialized/documentation_classes/disabled_model.py.

class Point:
    __slots__ = ('x', 'y')
    pass

Safe removal and retained references

Field-local policy belongs with that field declaration/fact. Removing a field must remove its slot/parameter/store/selection facts together. SlotNames is consumer-normalized in this tutorial, so removing only a FieldRow is not a complete deletion operation. A remaining named factory dependency must fail as a missing dependency; it must not silently bind the next field.

Dataclass's fixed-revision dataclass_field_removal canonical case records a richer before/after deletion with independent behavior and a retained-reference diagnostic. See consumer provenance. That consumer-specific normalizer is not generalized into a new YIDL field-removal API here.

For default/factory/keyword-only/accessor output consult the fixed consumer resources and generated outputs there. They supplement the minimal generic example, with their own exact verification boundary.