chore(server_fn_macro): improve docs (#1733)

This commit is contained in:
Fangdun Tsai 2023-09-19 08:48:47 +08:00 committed by GitHub
parent 2b59ae18bc
commit e706a69139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,10 @@
#![cfg_attr(feature = "nightly", feature(proc_macro_span))] #![cfg_attr(feature = "nightly", feature(proc_macro_span))]
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![deny(missing_docs)] #![deny(missing_docs)]
//! Implementation of the server_fn macro.
//! Implementation of the `server_fn` macro.
//! //!
//! This crate contains the implementation of the server_fn macro. [server_macro_impl] can be used to implement custom versions of the macro for different frameworks that allow users to pass a custom context from the server to the server function. //! This crate contains the implementation of the `server_fn` macro. [`server_macro_impl`] can be used to implement custom versions of the macro for different frameworks that allow users to pass a custom context from the server to the server function.
use proc_macro2::{Literal, Span, TokenStream as TokenStream2}; use proc_macro2::{Literal, Span, TokenStream as TokenStream2};
use proc_macro_error::abort; use proc_macro_error::abort;
@ -39,7 +40,7 @@ fn fn_arg_is_cx(f: &syn::FnArg, server_context: &ServerContext) -> bool {
} }
} }
/// The implementation of the server_fn macro. /// The implementation of the `server_fn` macro.
/// To allow the macro to accept a custom context from the server, pass a custom server context to this function. /// To allow the macro to accept a custom context from the server, pass a custom server context to this function.
/// **The Context comes from the server.** Optionally, the first argument of a server function /// **The Context comes from the server.** Optionally, the first argument of a server function
/// can be a custom context. This context can be used to inject dependencies like the HTTP request /// can be a custom context. This context can be used to inject dependencies like the HTTP request
@ -65,7 +66,6 @@ fn fn_arg_is_cx(f: &syn::FnArg, server_context: &ServerContext) -> bool {
/// } /// }
/// } /// }
/// ``` /// ```
pub fn server_macro_impl( pub fn server_macro_impl(
args: TokenStream2, args: TokenStream2,
body: TokenStream2, body: TokenStream2,