Skip to content

Conversation

@soareschen
Copy link
Collaborator

@soareschen soareschen commented Feb 17, 2025

Introduce a new #[cgp::re_export_imports] macro to be applied on a mod module, so that all use imports become pub use with #[doc(hidden)] applied to them.

This macro is mainly used to help with re-exporting component name types when defining presets using the cgp_preset! macro. It allows users to not have to manually add pub use on all component types that are wired in a preset. The #[doc(hidden)] attribute is applied, so that the re-exports are not shown in Rustdocs, or suggested by Rust Analyzer.

Given the following code:

#[cgp::re_export_imports]
mod preset {
    use foo::FooComponent;
    use bar::BarComponent;
}

would be expanded into:

mod preset {
    #[doc(hidden)]
    pub use foo::FooComponent;
    #[doc(hidden)]
    pub use bar::BarComponent;
}

pub use preset::*;

Notice that at the end, the macro re-exports all construts of the inner module to the module that contains the mod. This is so that we can still organize modules as files, and that the inner module is purely so that it can be wrapped around the macro.

@soareschen soareschen merged commit 6c4a36b into main Feb 17, 2025
5 checks passed
@soareschen soareschen deleted the re-export-imports branch February 17, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants