docs: leptos_router_macro::path (#2841)

This commit is contained in:
Chris 2024-08-16 20:19:38 -04:00 committed by GitHub
parent cfe2341dec
commit 621f112f4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View file

@ -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::*;

View file

@ -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 {