Skip to content

Commit d0d42d4

Browse files
authored
docs: add docs for starknet-macros (#642)
1 parent 7d8395f commit d0d42d4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
//!
4343
//! Contains procedural macros useful for this crate.
4444
45+
#![deny(missing_docs)]
46+
4547
#[doc = include_str!("../assets/CORE_README.md")]
4648
pub mod core {
4749
pub use starknet_core::*;

starknet-macros/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
//! Procedural macros for the `starknet` crate. This crate provides macros that help make defining
2+
//! certain compile-time constants easier.
3+
4+
#![deny(missing_docs)]
5+
16
use proc_macro::TokenStream;
27
use starknet_core::{
38
types::Felt,
49
utils::{cairo_short_string_to_felt, get_selector_from_name},
510
};
611
use syn::{parse_macro_input, LitStr};
712

13+
/// Defines a compile-time constant for a entrypoint selector of a Starknet contract.
814
#[proc_macro]
915
pub fn selector(input: TokenStream) -> TokenStream {
1016
let input = parse_macro_input!(input as LitStr);
@@ -26,6 +32,7 @@ pub fn selector(input: TokenStream) -> TokenStream {
2632
.unwrap()
2733
}
2834

35+
/// Defines a compile-time constant for a Cairo short string encoding from a human-readable string.
2936
#[proc_macro]
3037
pub fn short_string(input: TokenStream) -> TokenStream {
3138
let input = parse_macro_input!(input as LitStr);
@@ -47,6 +54,8 @@ pub fn short_string(input: TokenStream) -> TokenStream {
4754
.unwrap()
4855
}
4956

57+
/// Defines a compile-time constant for a field element from its decimal or hexadecimal
58+
/// representation.
5059
#[proc_macro]
5160
pub fn felt(input: TokenStream) -> TokenStream {
5261
let input = parse_macro_input!(input as LitStr);
@@ -73,6 +82,7 @@ pub fn felt(input: TokenStream) -> TokenStream {
7382
.unwrap()
7483
}
7584

85+
/// Defines a compile-time constant for a field element from its decimal representation.
7686
#[proc_macro]
7787
pub fn felt_dec(input: TokenStream) -> TokenStream {
7888
let input = parse_macro_input!(input as LitStr);
@@ -94,6 +104,7 @@ pub fn felt_dec(input: TokenStream) -> TokenStream {
94104
.unwrap()
95105
}
96106

107+
/// Defines a compile-time constant for a field element from its hexadecimal representation.
97108
#[proc_macro]
98109
pub fn felt_hex(input: TokenStream) -> TokenStream {
99110
let input = parse_macro_input!(input as LitStr);
@@ -116,7 +127,7 @@ pub fn felt_hex(input: TokenStream) -> TokenStream {
116127
}
117128

118129
#[cfg(feature = "use_imported_type")]
119-
fn field_element_path() -> &'static str {
130+
const fn field_element_path() -> &'static str {
120131
"Felt"
121132
}
122133

0 commit comments

Comments
 (0)