aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-08-05 16:30:47 +0200
committerHampusM <hampus@hampusmat.com>2023-08-05 16:30:47 +0200
commita1ec90ba16da8fd5b5209fa27604c4d4c62d8243 (patch)
treee0176350470fc289680d04efcfe9b6a601934969
parentb4718494e3a1759286caca1dd34c01db6c2f1214 (diff)
docs: improve injectable macro docs
-rw-r--r--Cargo.toml2
-rw-r--r--docs-rs-ext.css28
-rw-r--r--macros/src/lib.rs35
3 files changed, 49 insertions, 16 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 9558741..77b73c2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@ rust-version = "1.62.1"
[package.metadata.docs.rs]
all-features = true
-rustdoc-args = ["--cfg", "doc_cfg"]
+rustdoc-args = ["--cfg", "doc_cfg", "--extend-css", "docs-rs-ext.css"]
[features]
default = ["prevent-circular"]
diff --git a/docs-rs-ext.css b/docs-rs-ext.css
new file mode 100644
index 0000000..8db6c2d
--- /dev/null
+++ b/docs-rs-ext.css
@@ -0,0 +1,28 @@
+.cf {
+ display: flex;
+ margin-left: 0px;
+ margin-bottom: 5px;
+ min-height: 36px;
+ padding:0 2px;
+ align-items: center;
+ vertical-align: text-bottom;
+ white-space: unset !important;
+ border-radius: 3px;
+ width: fit-content;
+
+ background-color:var(--stab-background-color);
+ color:var(--main-color);
+
+ font-weight:normal;
+ font-size:0.875rem;
+}
+
+.cf code {
+ font-size: 0.875rem;
+ background-color: unset;
+ white-space: unset !important;
+}
+
+.cf strong {
+ margin-left: 3px;
+}
diff --git a/macros/src/lib.rs b/macros/src/lib.rs
index b261974..c228e73 100644
--- a/macros/src/lib.rs
+++ b/macros/src/lib.rs
@@ -39,8 +39,9 @@ mod test_utils;
#[allow(dead_code)]
const PACKAGE_VERSION: &str = env!("CARGO_PKG_VERSION");
-/// Makes a struct injectable. Thereby usable with [`DIContainer`] or
-/// [`AsyncDIContainer`].
+/// Makes a type injectable.
+///
+/// Generates an implementation of [`Injectable`].
///
/// # Arguments
/// * (Optional) A interface trait the struct implements.
@@ -59,9 +60,14 @@ const PACKAGE_VERSION: &str = env!("CARGO_PKG_VERSION");
/// is given.
///
/// #### `async`
+/// <span class="cf">Available on <strong>crate feature <code>async</code></strong> only.
+/// </span>
+///
/// **Value:** boolean literal<br>
/// **Default:** `false`<br>
-/// Mark as async.
+/// Generate an implementation of [`AsyncInjectable`] instead of [`Injectable`].
+///
+/// This flag must be set to `true` for the type to be usable with [`AsyncDIContainer`].
///
/// #### `constructor`
/// **Value:** identifier<br>
@@ -69,12 +75,10 @@ const PACKAGE_VERSION: &str = env!("CARGO_PKG_VERSION");
/// Constructor method name.
///
/// # Important
-/// When no interface trait argument is given, you should either manually
-/// declare the interface with the [`declare_interface!`] macro or use
-/// the [`di_container_bind`] macro to create a DI container binding.
-///
-/// You can however also use the concrete type as the interface. As it is declared as such
-/// by default if the `no_declare_concrete_interface` flag is not set.
+/// When no interface trait argument is given, you have three options
+/// - Manually declare the interface with the [`declare_interface!`] macro.
+/// - Use the [`di_container_bind`] macro to create a DI container binding.
+/// - Use the concrete type as the interface.
///
/// # Examples
/// ```
@@ -96,8 +100,8 @@ const PACKAGE_VERSION: &str = env!("CARGO_PKG_VERSION");
/// Attributes specific to impls with this attribute macro.
///
/// ### Named
-/// Used inside the `new` method before a dependency argument. Declares the name of the
-/// dependency. Should be given the name quoted inside parenthesis.
+/// Used inside the of constructor method before a dependency argument. Declares the name
+/// of the dependency. Should be given the name quoted inside parenthesis.
///
/// The [`macro@named`] ghost attribute macro can be used for intellisense and
/// autocompletion for this attribute.
@@ -135,10 +139,11 @@ const PACKAGE_VERSION: &str = env!("CARGO_PKG_VERSION");
/// # impl IKnight for Knight {}
/// ```
///
-/// [`DIContainer`]: https://docs.rs/syrette/latest/syrette/di_container/struct.DIContainer.html
-/// [`AsyncDIContainer`]: https://docs.rs/syrette/latest/syrette/async_di_container/struct.AsyncDIContainer.html
-/// [`Injectable`]: https://docs.rs/syrette/latest/syrette/interfaces/injectable/trait.Injectable.html
-/// [`di_container_bind`]: https://docs.rs/syrette/latest/syrette/macro.di_container_bind.html
+/// [`DIContainer`]: ../syrette/di_container/blocking/struct.DIContainer.html
+/// [`AsyncDIContainer`]: ../syrette/di_container/asynchronous/struct.AsyncDIContainer.html
+/// [`Injectable`]: ../syrette/interfaces/injectable/trait.Injectable.html
+/// [`AsyncInjectable`]: ../syrette/interfaces/async_injectable/trait.AsyncInjectable.html
+/// [`di_container_bind`]: ../syrette/macro.di_container_bind.html
#[cfg(not(tarpaulin_include))]
#[proc_macro_error]
#[proc_macro_attribute]