gilt-derive 0.13.0

Derive macros for the gilt terminal formatting library
Documentation
1
2
3
4
5
---
source: crates/gilt-derive/src/lib.rs
expression: render_tokens(&ts)
---
impl Item { # [doc = r" Renders this struct as a card (a Panel with labeled key-value fields)."] # [doc = r""] # [doc = r#" Each non-skipped field becomes a line `"Label: value"`. Field styles"#] # [doc = r" are applied as markup tags around the label."] pub fn to_card (& self) -> gilt :: panel :: Panel { let mut lines : Vec < String > = Vec :: new () ; lines . push (format ! ("{}: {}" , "Title" , self . title)) ; let content = gilt :: text :: Text :: from_markup (& lines . join ("\n")) . unwrap_or_else (| _ | gilt :: text :: Text :: from (lines . join ("\n") . as_str ())) ; let mut panel = gilt :: panel :: Panel :: new (content) ; panel . title = Some (gilt :: text :: Text :: from ("Item")) ; panel } # [doc = r" Creates a [`gilt::columns::Columns`] from a slice of items."] # [doc = r""] # [doc = r" Each item is rendered as a Panel card and laid out in columns."] # [doc = r" Struct-level `#[columns(...)]` attributes control the column layout."] pub fn to_columns (items : & [Self]) -> gilt :: columns :: Columns { let mut cols = gilt :: columns :: Columns :: new () ; # [allow (unused_variables)] let max_width : usize = 80 ; for item in items { let card = item . to_card () ; cols . add_renderable (& format ! ("{}" , card)) ; } cols } }