Skip to content

Commit 1b65b45

Browse files
committed
Allow doc comments for exported components
1 parent 87fb3c9 commit 1b65b45

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

examples/02-todo/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ impl Component for App {
9999
}
100100
}
101101

102-
export_components! { App }
102+
export_components! {
103+
/// This is the entry component for our Todo application
104+
App
105+
}
103106

104107
struct TaskList {
105108
tasks: ValueContainer<Vec<(bool, Rc<str>)>>,

src/macros.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,30 @@ macro_rules! classnames {
258258
/// # type Error = JsValue;
259259
/// # fn try_from(_: JsValue) -> Result<Self, Self::Error> { todo!() }
260260
/// # }
261-
/// export_components! { App as CounterApp, Counter }
261+
/// export_components! {
262+
/// /// Some doc comment for the exported component.
263+
/// App as CounterApp,
264+
/// Counter
265+
/// }
262266
/// ```
263267
#[macro_export]
264268
macro_rules! export_components {
265269
{} => {};
266-
{ $Component:ident $( , $( $tail:tt )* )? } => {
267-
$crate::export_components! { $Component as $Component $( , $( $tail )* )? }
270+
{
271+
$( #[$meta:meta] )*
272+
$Component:ident $( , $( $tail:tt )* )?
273+
} => {
274+
$crate::export_components! {
275+
$( #[$meta] )*
276+
$Component as $Component $( , $( $tail )* )?
277+
}
268278
};
269-
{ $Component:ty as $Name:ident $( , $( $tail:tt )* )? } => {
279+
{
280+
$( #[$meta:meta] )*
281+
$Component:ty as $Name:ident $( , $( $tail:tt )* )?
282+
} => {
270283
$crate::paste! {
284+
$( #[$meta] )*
271285
#[allow(non_snake_case)]
272286
#[allow(dead_code)]
273287
#[doc(hidden)]

0 commit comments

Comments
 (0)