Document the macros.
Add code examples for the macros
This commit is contained in:
parent
642994a194
commit
06aa9e3175
@ -3,8 +3,7 @@ use proc_macro2::{Ident, TokenStream};
|
||||
use quote::{quote, quote_spanned};
|
||||
use syn::{punctuated::Punctuated, token::Comma, Data, DataEnum, Fields, Lit, Meta, Variant};
|
||||
|
||||
/// FIXME
|
||||
/// Method to derive default column names from a &str
|
||||
/// Derive a Column name for an enum type
|
||||
pub fn impl_default_as_str(ident: &Ident, data: &Data) -> syn::Result<TokenStream> {
|
||||
let variants = match data {
|
||||
syn::Data::Enum(DataEnum { variants, .. }) => variants,
|
||||
|
@ -106,12 +106,15 @@ pub fn derive_column(input: TokenStream) -> TokenStream {
|
||||
}
|
||||
|
||||
/// Derive a column if column names are not in snake-case
|
||||
/// ### Usage
|
||||
/// ```
|
||||
/// #[derive(Copy, Clone, Debug, EnumIter, DeriveCustomColumn)]
|
||||
/// pub enum Column {
|
||||
/// Id,
|
||||
/// Name,
|
||||
/// VendorId,
|
||||
/// }
|
||||
/// ```
|
||||
#[proc_macro_derive(DeriveCustomColumn)]
|
||||
pub fn derive_custom_column(input: TokenStream) -> TokenStream {
|
||||
let DeriveInput { ident, data, .. } = parse_macro_input!(input);
|
||||
@ -165,7 +168,7 @@ pub fn derive_active_model(input: TokenStream) -> TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
/// FIXME Derive into an active model
|
||||
/// Derive into an active model
|
||||
#[proc_macro_derive(DeriveIntoActiveModel, attributes(sea_orm))]
|
||||
pub fn derive_into_active_model(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
Loading…
x
Reference in New Issue
Block a user