From d0d42d445d22dfa5c37180338b1f0d58c963408b Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Mon, 29 Jul 2024 17:02:47 +0800 Subject: [PATCH] docs: add docs for `starknet-macros` (#642) --- src/lib.rs | 2 ++ starknet-macros/src/lib.rs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index cf90871b..ce1f491c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,6 +42,8 @@ //! //! Contains procedural macros useful for this crate. +#![deny(missing_docs)] + #[doc = include_str!("../assets/CORE_README.md")] pub mod core { pub use starknet_core::*; diff --git a/starknet-macros/src/lib.rs b/starknet-macros/src/lib.rs index 79d1aade..eb7114ad 100644 --- a/starknet-macros/src/lib.rs +++ b/starknet-macros/src/lib.rs @@ -1,3 +1,8 @@ +//! Procedural macros for the `starknet` crate. This crate provides macros that help make defining +//! certain compile-time constants easier. + +#![deny(missing_docs)] + use proc_macro::TokenStream; use starknet_core::{ types::Felt, @@ -5,6 +10,7 @@ use starknet_core::{ }; use syn::{parse_macro_input, LitStr}; +/// Defines a compile-time constant for a entrypoint selector of a Starknet contract. #[proc_macro] pub fn selector(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as LitStr); @@ -26,6 +32,7 @@ pub fn selector(input: TokenStream) -> TokenStream { .unwrap() } +/// Defines a compile-time constant for a Cairo short string encoding from a human-readable string. #[proc_macro] pub fn short_string(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as LitStr); @@ -47,6 +54,8 @@ pub fn short_string(input: TokenStream) -> TokenStream { .unwrap() } +/// Defines a compile-time constant for a field element from its decimal or hexadecimal +/// representation. #[proc_macro] pub fn felt(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as LitStr); @@ -73,6 +82,7 @@ pub fn felt(input: TokenStream) -> TokenStream { .unwrap() } +/// Defines a compile-time constant for a field element from its decimal representation. #[proc_macro] pub fn felt_dec(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as LitStr); @@ -94,6 +104,7 @@ pub fn felt_dec(input: TokenStream) -> TokenStream { .unwrap() } +/// Defines a compile-time constant for a field element from its hexadecimal representation. #[proc_macro] pub fn felt_hex(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as LitStr); @@ -116,7 +127,7 @@ pub fn felt_hex(input: TokenStream) -> TokenStream { } #[cfg(feature = "use_imported_type")] -fn field_element_path() -> &'static str { +const fn field_element_path() -> &'static str { "Felt" }