Skip to content

Commit

Permalink
Add small doc on blueprint macro
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Aug 2, 2024
1 parent 0d2b565 commit 4269f52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions cursive-macros/src/builder/dummy_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub fn blueprint(_: TokenStream, _: TokenStream) -> TokenStream {
TokenStream::new()
}

// Just return the annotated function unchanged.
pub fn callback_helpers(item: TokenStream) -> TokenStream {
item
}
17 changes: 17 additions & 0 deletions cursive-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ pub fn callback_helpers(_attrs: TokenStream, item: TokenStream) -> TokenStream {
}

/// Defines a blueprint for creating a view from config.
///
/// It should be added to a type which defines how to build the view.
///
/// # Examples
///
/// ```rust,ignore
/// #[cursive::blueprint(TextView::empty())]
/// struct BlueprintForTextview {
/// content: StyledString,
/// }
/// ```
///
/// This recipe will:
/// * Create a base view with `TextView::empty()`.
/// * Look for a `content` key in the given config.
/// * Try to resolve the associated value to a `StyledString`.
/// * Call `set_content` on the base with the resulting `StyledString`.
#[proc_macro_attribute]
pub fn blueprint(attrs: TokenStream, item: TokenStream) -> TokenStream {
builder::blueprint(attrs, item)
Expand Down

0 comments on commit 4269f52

Please sign in to comment.