# Examples
This directory contains examples demonstrating various features of `derive-defs`.
## Running Examples
```bash
# Basic usage
cargo run --example basic
# Inheritance chains
cargo run --example inheritance
# Circular dependency detection
cargo run --example circular_detection
# Code generation
cargo run --example code_generation
# Complete example with all features
cargo run --example complete
```
## Example Descriptions
### `basic.rs`
Demonstrates basic TOML parsing and code generation. Shows how to:
- Create a TOML configuration file
- Parse it using `derive_defs::parser`
- Resolve inheritance with `derive_defs::resolver`
- Generate proc-macro code
### `inheritance.rs`
Shows how the `extends` keyword works for creating inheritance chains.
Demonstrates trait accumulation through multiple levels of inheritance.
### `circular_detection.rs`
Demonstrates error handling when circular dependencies are detected
in the inheritance graph.
### `code_generation.rs`
Shows the complete code generation process, including:
- Parsing configuration
- Resolving definitions
- Generating Rust proc-macro code
### `complete.rs`
A comprehensive example showing all features:
- Basic definitions
- Inheritance
- Attributes
- Cross-file includes (simulated)
- Code generation
## Creating Your Own Example
To create a new example:
1. Create a new file in this directory: `examples/my_example.rs`
2. Add a module-level doc comment explaining the example
3. Use `std::env::temp_dir()` for temporary files
4. Clean up temporary files at the end
```rust
//! My example description.
//!
//! # Running the example
//!
//! ```bash
//! cargo run --example my_example
//! ```
fn main() {
// Your example code here
}
```