lucy_macro/lib.rs
1//! Proc-macro crate for the Lucy documentation framework.
2//!
3//! Provides three attribute macros to annotate Axum handlers:
4//! - [`lucy_http`] — HTTP REST endpoints
5//! - [`lucy_ws`] — WebSocket endpoints
6//! - [`lucy_mqtt`] — MQTT topics
7//!
8//! # Example
9//! ```rust,ignore
10//! #[lucy_macro::lucy_http(method = "GET", path = "/health", description = "Health check")]
11//! async fn health_handler() -> &'static str { "ok" }
12//! ```
13
14use proc_macro::TokenStream;
15
16mod http;
17mod mqtt;
18mod ws;
19
20/// Annotates an Axum HTTP handler for Lucy documentation generation.
21///
22/// # Arguments
23/// - `method` — HTTP verb (GET, POST, PUT, DELETE, PATCH)
24/// - `path` — URL path (e.g. `/api/users`)
25/// - `description` — Optional human-readable description
26#[proc_macro_attribute]
27pub fn lucy_http(attr: TokenStream, item: TokenStream) -> TokenStream {
28 http::expand(attr, item)
29}
30
31/// Annotates an Axum WebSocket handler for Lucy documentation generation.
32///
33/// # Arguments
34/// - `path` — WebSocket upgrade path (e.g. `/ws/events`)
35/// - `description` — Optional human-readable description
36#[proc_macro_attribute]
37pub fn lucy_ws(attr: TokenStream, item: TokenStream) -> TokenStream {
38 ws::expand(attr, item)
39}
40
41/// Annotates an MQTT topic handler for Lucy documentation generation.
42///
43/// # Arguments
44/// - `topic` — MQTT topic string (e.g. `sensors/temperature`)
45/// - `description` — Optional human-readable description
46#[proc_macro_attribute]
47pub fn lucy_mqtt(attr: TokenStream, item: TokenStream) -> TokenStream {
48 mqtt::expand(attr, item)
49}