aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--macros/src/lib.rs77
-rw-r--r--src/lib.rs32
2 files changed, 58 insertions, 51 deletions
diff --git a/macros/src/lib.rs b/macros/src/lib.rs
index 6e3fc0a..eb3a2be 100644
--- a/macros/src/lib.rs
+++ b/macros/src/lib.rs
@@ -70,7 +70,6 @@ use libs::intertrait_macros::gen_caster::generate_caster;
/// {
/// pub fn new(
/// #[named("tough")] tough_armor: TransientPtr<dyn IArmor>,
-///
/// #[named("light")] light_armor: TransientPtr<dyn IArmor>,
/// ) -> Self
/// {
@@ -145,51 +144,23 @@ pub fn injectable(args_stream: TokenStream, impl_stream: TokenStream) -> TokenSt
///
/// # Examples
/// ```
-/// use std::collections::HashMap;
-///
-/// use syrette::factory;
-/// use syrette::interfaces::factory::IFactory;
-///
-/// enum ConfigValue
-/// {
-/// String(String),
-/// Bool(bool),
-/// Int(i32),
-/// None,
-/// }
-///
-/// trait IConfigurator
-/// {
-/// fn configure(&self, key: String, value: ConfigValue);
-/// }
-///
-/// struct Configurator
-/// {
-/// config: HashMap<String, ConfigValue>,
-/// }
-///
-/// impl Configurator
-/// {
-/// fn new(keys: Vec<String>) -> Self
-/// {
-/// Self {
-/// config: HashMap::from(
-/// keys.iter()
-/// .map(|key| (key.clone(), ConfigValue::None))
-/// .collect::<HashMap<_, _>>(),
-/// ),
-/// }
-/// }
-/// }
-///
-/// impl IConfigurator for Configurator
-/// {
-/// fn configure(&self, key: String, value: ConfigValue)
-/// {
-/// // ...
-/// }
-/// }
-///
+/// # use syrette::factory;
+/// # use syrette::interfaces::factory::IFactory;
+/// #
+/// # trait IConfigurator {}
+/// #
+/// # struct Configurator {}
+/// #
+/// # impl Configurator
+/// # {
+/// # fn new() -> Self
+/// # {
+/// # Self {}
+/// # }
+/// # }
+/// #
+/// # impl IConfigurator for Configurator {}
+/// #
/// #[factory]
/// type IConfiguratorFactory = dyn IFactory<(Vec<String>,), dyn IConfigurator>;
/// ```
@@ -228,6 +199,19 @@ pub fn factory(_: TokenStream, type_alias_stream: TokenStream) -> TokenStream
///
/// # Arguments
/// {Implementation} -> {Interface}
+///
+/// # Examples
+/// ```
+/// # use syrette::declare_interface;
+/// #
+/// # trait INinja {}
+/// #
+/// # struct Ninja {}
+/// #
+/// # impl INinja for Ninja {}
+/// #
+/// declare_interface!(Ninja -> INinja);
+/// ```
#[proc_macro]
pub fn declare_interface(input: TokenStream) -> TokenStream
{
@@ -267,7 +251,6 @@ pub fn declare_interface(input: TokenStream) -> TokenStream
/// {
/// pub fn new(
/// #[syrette::named("strong")] strong_weapon: TransientPtr<dyn IWeapon>,
-///
/// #[syrette::named("weak")] weak_weapon: TransientPtr<dyn IWeapon>,
/// ) -> Self
/// {
diff --git a/src/lib.rs b/src/lib.rs
index cac6ffe..8908143 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -38,6 +38,30 @@ mod provider;
///
/// # Arguments
/// {interface} => {implementation}, {DI container variable name}
+///
+/// # Examples
+/// ```
+/// # use syrette::{di_container_bind, DIContainer, injectable};
+/// #
+/// # trait INinja {}
+/// #
+/// # struct Ninja {}
+/// #
+/// # #[injectable]
+/// # impl Ninja
+/// # {
+/// # fn new() -> Self
+/// # {
+/// # Self {}
+/// # }
+/// # }
+/// #
+/// # impl INinja for Ninja {}
+/// #
+/// let mut di_container = DIContainer::new();
+///
+/// di_container_bind!(INinja => Ninja, di_container);
+/// ```
#[macro_export]
macro_rules! di_container_bind {
($interface: path => $implementation: ty, $di_container: ident) => {
@@ -62,8 +86,8 @@ macro_rules! di_container_bind {
///
/// # Examples
/// ```
-/// use syrette::declare_default_factory;
-///
+/// # use syrette::declare_default_factory;
+/// #
/// trait IParser
/// {
/// // Methods and etc here...
@@ -75,8 +99,8 @@ macro_rules! di_container_bind {
/// The expanded equivelent of this would be
///
/// ```
-/// use syrette::declare_default_factory;
-///
+/// # use syrette::declare_default_factory;
+/// #
/// trait IParser {
/// // Methods and etc here...
/// }