rustdoc::html::render::print_item

Macro item_template

source
macro_rules! item_template {
    (
        $(#[$meta:meta])*
        struct $name:ident<'a, 'cx> {
            cx: RefCell<&'a mut Context<'cx>>,
            it: &'a clean::Item,
            $($field_name:ident: $field_ty:ty),*,
        },
        methods = [$($methods:tt),* $(,)?]
    ) => { ... };
}
Expand description

Generates a Rinja template struct for rendering items with common methods.

Usage:

item_template!(
    #[template(path = "<template.html>", /* additional values */)]
    /* additional meta items */
    struct MyItem<'a, 'cx> {
        cx: RefCell<&'a mut Context<'cx>>,
        it: &'a clean::Item,
        /* additional fields */
    },
    methods = [ /* method names (comma separated; refer to macro definition of `item_template_methods!()`) */ ]
)

NOTE: ensure that the generic lifetimes ('a, 'cx) and required fields (cx, it) are identical (in terms of order and definition).