From 621f112f4c0b356f2e26cacd2bfd7ced22b5feca Mon Sep 17 00:00:00 2001 From: Chris <89366859+chrisp60@users.noreply.github.com> Date: Fri, 16 Aug 2024 20:19:38 -0400 Subject: [PATCH] docs: `leptos_router_macro::path` (#2841) --- router/src/lib.rs | 1 + router_macro/src/lib.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/router/src/lib.rs b/router/src/lib.rs index f5301bad6..743321a70 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -19,6 +19,7 @@ mod ssr_mode; mod static_route; pub use generate_route_list::*; +#[doc(inline)] pub use leptos_router_macro::path; pub use matching::*; pub use method::*; diff --git a/router_macro/src/lib.rs b/router_macro/src/lib.rs index 9afe47b24..604203f8f 100644 --- a/router_macro/src/lib.rs +++ b/router_macro/src/lib.rs @@ -6,6 +6,25 @@ use quote::{quote, ToTokens}; const RFC3986_UNRESERVED: [char; 4] = ['-', '.', '_', '~']; const RFC3986_PCHAR_OTHER: [char; 1] = ['@']; +/// Constructs a path for use in a [`leptos_router::Route`] definition. +/// +/// Note that this is an optional convenience. Manually defining route segments +/// is equivalent. +/// +/// # Examples +/// +/// ```rust +/// use leptos_router::{path, ParamSegment, StaticSegment, WildcardSegment}; +/// +/// let path = path!("/foo/:bar/*any"); +/// let output = ( +/// StaticSegment("foo"), +/// ParamSegment("bar"), +/// WildcardSegment("any"), +/// ); +/// +/// assert_eq!(path, output); +/// ``` #[proc_macro_error::proc_macro_error] #[proc_macro] pub fn path(tokens: TokenStream) -> TokenStream {