Metadata-Version: 2.4
Name: patisserie
Version: 1.1.0
Summary: Language-agnostic boilerplate generator from YAML data models
Author-email: Peter Verhas <peter.verhas@gmail.com>
License-Expression: MIT OR Apache-2.0
Project-URL: Homepage, https://github.com/yourusername/pati
Project-URL: Documentation, https://github.com/yourusername/pati/tree/main/docs
Project-URL: Repository, https://github.com/yourusername/pati.git
Project-URL: Issues, https://github.com/yourusername/pati/issues
Keywords: code-generation,boilerplate,yaml,jinja2,templates
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Code Generators
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE-MIT
License-File: LICENSE-APACHE
Requires-Dist: pyyaml>=6.0
Requires-Dist: jinja2>=3.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: flake8>=5.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Requires-Dist: build>=0.9; extra == "dev"
Dynamic: license-file

# Patisserie

![Pâtisserie](logo.svg)

<p align="center">
  <a href="https://pypi.org/project/patisserie/"><img src="https://img.shields.io/pypi/v/patisserie.svg" alt="PyPI Version"/></a>
  <img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="Python 3.8+"/>
  <a href="LICENSE-MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"/></a>
  <a href="LICENSE-APACHE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache 2.0"/></a>
</p>

**Language-agnostic boilerplate code generator from YAML data models and Jinja2 templates.**

Define your data model once in YAML. Generate boilerplate code in any language (Java, Rust, Python, Go, TypeScript, etc.) using Jinja2 templates.

## Why Pattiserie?

- **Single Source of Truth**: Define your data model once, generate code for multiple languages
- **Template-Driven**: Use Jinja2 to create language-specific templates
- **Configuration as Code**: YAML schemas with anchors for DRY configuration
- **Language Agnostic**: Generate Java, Rust, Python, Go, TypeScript, or any text-based format
- **Zero Runtime Dependencies**: Just Python, PyYAML, and Jinja2

## Quick Start

### Installation

    pip install patisserie

### 5-Minute Example

1. **Initialize a project:**


     mkdir my-project && cd my-project
     pati mise

The `pati mise` command will create the `.pati` directory for you and create the sample `schema.yaml` and templates files you can edit. 

2. **Edit your data model** (`.pati/schema.yaml`):
   ```yaml
   jobs:
     user_entity:
       template: entity.java.j2
       output: generated/User.java
       context:
         package: com.example
         class_name: User
         fields:
           - name: id
             type: Long
           - name: username
             type: String
   ```

3. **Customize a template** (`.pati/tmplts/entity.java.j2`):
   ```jinja2
   package {{ package }};
   
   public class {{ class_name }} {
   {% for field in fields %}
       private {{ field.type }} {{ field.name }};
   {% endfor %}
   }
   ```

4. **Generate code:**
   ```bash
   pati cuire
   ```

5. **Check the output:**
   ```bash
   cat generated/User.java
   ```

## Features

### 📋 YAML Schema Support
- Define jobs with template, output, and context
- YAML anchors (`&name`) and aliases (`*name`) for reusable config
- Merge key (`<<: *alias`) for DRY configuration
- Full PyYAML support for complex structures

### 🎨 Jinja2 Templates
- Variables: `{{ variable }}`
- Loops: `{% for item in items %}`
- Conditionals: `{% if condition %}`
- Filters: `{{ value | filter }}`
- Complete Jinja2 feature set

### 🛠️ CLI Tools
```bash
# Generate all jobs from default schema (.pati/schema.yaml)
pati cuire

# Generate specific job(s) by name
pati cuire pojo_user

# Generate jobs matching a glob pattern
pati cuire 'pojo*'

# Generate jobs matching multiple patterns
pati cuire 'pojo*' dto_user

# Generate from a specific schema
pati cuire --config path/to/schema.yaml

# Dry run (preview without writing)
pati cuire --dry-run

# Override output directory
pati cuire --output-dir /path/to/output

# Initialize new project, creating a sample yaml
# and the sample template files in the directory .pati
pati mise
```

### 📦 Built-in Examples
- **Java Spring Boot**: Entities, DTOs, Repositories, Liquibase migrations
- **Rust SQLx**: Models with SQLx derive macros
- **Python SQLAlchemy**: ORM models
- **Go GORM**: Struct definitions with GORM tags

> These examples are for demonstration purpose only.
> They are simplified.
> Real word examples can start from these templates, but they will likely be extended.

## Documentation

- **[Installation Guide](docs/INSTALLATION.md)** — Setup and troubleshooting
- **[Quick Start Guide](docs/QUICKSTART.md)** — Get running in 5 minutes
- **[YAML Schema Reference](docs/YAML_SCHEMA.md)** — Complete schema documentation
- **[Jinja2 Template Syntax](docs/TEMPLATE_SYNTAX.md)** — Template language reference
- **[Real-World Examples](docs/EXAMPLES.md)** — Complete working examples
- **[Why Pâtisserie?](docs/NAME.md)** — The philosophy behind the name

## Example Use Cases

### Multi-language ORM Models
```yaml
jobs:
  user_java:
    template: entity.java.j2
    output: src/main/java/User.java
    context: { class_name: User, fields: [...] }
  
  user_python:
    template: model.py.j2
    output: models/user.py
    context: { class_name: User, fields: [...] }
  
  user_rust:
    template: model.rs.j2
    output: src/models/user.rs
    context: { struct_name: User, fields: [...] }
```

### Microservice Scaffolding
Generate controllers, services, and DTOs from a single data model schema.

### API Client/Server Code
Generate OpenAPI specs, request/response models, and route handlers.

### Database Migrations
Generate SQL migrations, Liquibase changesets, or Flyway migrations.

### Configuration Files
Generate Docker Compose, Kubernetes manifests, or Terraform code.

## Architecture

```
schema.yaml          Template files              Generated code
     │               (Jinja2)                         │
     │                   │                            │
     └──────────────────────────────────────────────────→
                    pati
          (config loader + generator)
```

1. Load YAML schema
2. Extract job configuration
3. Initialize Jinja2 environment
4. Render each template with context
5. Write generated files

## Development

This chapter is about how to develop the code of Pâtisserie itself.

### Setup
```bash
git clone https://github.com/yourusername/pati.git
cd pati
pip install -e ".[dev]"
```

### Running Tests
```bash
pytest tests/ -v --cov
```

### Building
```bash
./build.sh
```

### Releasing
```bash
./release.sh 0.2.0
```

## CLI Reference

```bash
# Generate from default schema
pati cuire [JOB ...] [OPTIONS]     # French: "to bake"
pati generate [JOB ...] [OPTIONS]  # English alias — identical
  JOB                     Job name(s) or glob patterns to run (default: all)
                          Examples: pojo_user  'pojo*'  'pojo*' dto_user
  --config, -c FILE       Path to schema file (default: .pati/schema.yaml)
  --dry-run               Show what would be generated without writing
  --output-dir DIR        Override output directory for all jobs

# Initialize new project structure
pati mise [OPTIONS]       # French: "mise en place"
pati init [OPTIONS]       # English alias — identical
  --output, -o DIR        Output directory (default: current directory)

# Show version
pati --version, -v

# Logging level (global flags, mutually exclusive)
pati --verbose COMMAND   # debug output
pati --quiet COMMAND     # warnings and errors only
pati -q COMMAND
pati --silent COMMAND    # errors only
pati -s COMMAND

# Show help
pati --help
pati COMMAND --help
```

## Project Structure

```
pati/
├── src/pati/           # Main package
│   ├── __init__.py          # Package metadata
│   ├── cli.py               # CLI entry point
│   ├── config.py            # YAML config loader
│   ├── generator.py         # Template generator
│   └── utils.py             # Helper functions
├── examples/                # Example templates
│   ├── java-spring/
│   ├── rust-sqlx/
│   ├── python-sqlalchemy/
│   └── go-gorm/
├── tests/                   # Test suite
├── docs/                    # Documentation
├── setup.py                 # Package metadata
├── pyproject.toml          # Modern Python config
├── build.sh                 # Build script
└── release.sh              # Release script
```

## License

Licensed under either of:

- [MIT License](LICENSE-MIT)
- [Apache License, Version 2.0](LICENSE-APACHE)

at your option.

## Contributing

Contributions welcome! Please:

1. Fork the repository
2. Create a feature branch
3. Write tests for new features
4. Ensure tests pass: `pytest tests/ -v --cov`
5. Submit a pull request

## Support

- **Issues**: [GitHub Issues](https://github.com/yourusername/pati/issues)
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/pati/discussions)
- **Docs**: [Full Documentation](docs/)

## Roadmap

- [ ] Watch mode for live template development
- [ ] Template inheritance and includes
- [ ] Custom Jinja2 filters and globals
- [ ] Schema validation with JSON Schema
- [ ] Plugin system for extensibility
- [ ] Web UI for template editing
- [ ] Template marketplace

---

**Ready to generate? → [Quick Start Guide](docs/QUICKSTART.md)**
