1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! `#[derive(PyEnum)]` procedural macro.
//!
//! This is the entry-point crate. Parsing, validation, and codegen live in
//! the submodules and are wired together by [`derive_pyenum`] below. The
//! generated code references only items re-exported from `pyenum::__private`
//! so the output is feature-flag-free — the runtime crate's `compat` module
//! resolves those names per the active `pyo3-0_XX` feature.
use TokenStream;
/// Derive a `pyenum::PyEnum` implementation for a unit-variant Rust enum.
///
/// Enum-level attributes (all optional):
///
/// * `#[pyenum(base = "Enum" | "IntEnum" | "StrEnum" | "Flag" | "IntFlag")]`
/// — select the Python base class. Defaults to `"Enum"`.
/// * `#[pyenum(name = "...")]` — override the Python class name. Defaults
/// to the Rust enum identifier.
///
/// Variant-level attributes (all optional, mutually exclusive with a Rust
/// discriminant on the same variant):
///
/// * `#[pyenum(value = "...")]` — explicit Python string value. Only
/// valid when the enum base is `StrEnum` or `Enum`. Without this
/// attribute (and without a Rust discriminant), `StrEnum` variants
/// default to Python's `auto()` semantics, which lowercase the variant
/// name.