# PyWatt SDK Procedural Macro Integration Module
This directory is the integration point for PyWatt SDK's procedural macros under the `proc_macros` feature.
## Overview
Procedural macros in PyWatt simplify module initialization by generating boilerplate code for the `#[pywatt::module]` attribute. This directory:
- Defines how/when the `module` macro is exported.
- Documents the connection to the dedicated proc-macro crate.
The actual macro implementations live in a separate crate (`pywatt_macros`) with `crate-type = "proc-macro"`.
## Directory Structure
```text
src/internal/pywatt_macros/
├── mod.rs # Conditional re-export of `module` macro
└── README.md # This documentation
```
## Usage
In your `Cargo.toml`, enable the feature:
```toml
[dependencies]
pywatt_sdk = { version = "*", features = ["proc_macros"] }
```
Then import the macro:
```rust
use pywatt_sdk::module;
#[module]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Module entrypoint generated by macro
Ok(())
}
```
## Cargo Features
| `proc_macros` | Enables procedural macro support (`#[module]`). |
## Integration with Proc-macro Crate
The dedicated `pywatt_macros` crate contains the real implementation:
- **Crate type**: `proc-macro`
- **Location**: `<workspace_root>/pywatt_macros`
- **Exports**: `module` attribute.
When `proc_macros` is enabled, `mod.rs` here re-exports that macro:
```rust
#[cfg(feature = "proc_macros")]
pub use crate::internal::macros::module;
```
## Contributing
1. Implement new macros in the `pywatt_macros` crate.
2. Add tests/examples in the `pywatt_macros` crate and update documentation here.
3. Ensure feature gating and re-export paths remain correct.
## See Also
- `src/internal/macros.rs` for basic `module_init()` support.
- `<workspace_root>/pywatt_macros` for macro code.