Building with Codegen
Collections
Codegen enables traversing and manipulating collections through the List and Dict classes.
These APIs work consistently across Python and TypeScript while preserving formatting and structure.
Core Concepts
The List and Dict classes provide a consistent interface for working with ordered sequences of elements. Key features include:
- Standard sequence operations (indexing, length, iteration)
- Automatic formatting preservation
- Safe modification operations
- Language-agnostic behavior
- Comment and whitespace preservation
Collections handle:
- Proper indentation
- Delimiters (commas, newlines)
- Multi-line formatting
- Leading/trailing whitespace
- Nested structures
List Operations
Lists in both Python and TypeScript can be manipulated using the same APIs:
Single vs Multi-line Lists
Collections automatically preserve formatting:
Dictionary Operations
Dictionaries provide a similar consistent interface:
Was this page helpful?