Skip to content

Commit

Permalink
doc refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandros committed Oct 20, 2024
1 parent 7c1b9d6 commit d390a1c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 32 deletions.
3 changes: 3 additions & 0 deletions ferrunix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ thiserror = "1"
inventory = "0.3.1"
tokio = { version = "1.5", default-features = false, features = ["sync"], optional = true }
async-trait = { version = "0.1", optional = true }

[package.metadata."docs.rs"]
all-features = true
12 changes: 6 additions & 6 deletions ferrunix-core/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ pub trait Dep: Registerable + private::Sealed {
/// Looks up the dependency in `registry`, and constructs a new [`Dep`].
///
/// This function is allowed to panic, if the type isn't registered.
#[cfg(not(feature = "tokio"))]
#[cfg(any(doc, not(feature = "tokio")))]
fn new(registry: &Registry) -> Self;

/// Looks up the dependency in `registry`, and constructs a new [`Dep`].
///
/// This function is allowed to panic, if the type isn't registered.
#[cfg(feature = "tokio")]
#[cfg(any(doc, feature = "tokio"))]
fn new(
registry: &Registry,
) -> impl std::future::Future<Output = Self> + Send
Expand Down Expand Up @@ -118,7 +118,7 @@ impl<T: Registerable> Dep for Transient<T> {
///
/// # Panic
/// This function panics if the `T` isn't registered.
#[cfg(not(feature = "tokio"))]
#[cfg(any(doc, not(feature = "tokio")))]
fn new(registry: &Registry) -> Self {
Self {
inner: registry.get_transient::<T>().expect(
Expand All @@ -132,7 +132,7 @@ impl<T: Registerable> Dep for Transient<T> {
///
/// # Panic
/// This function panics if the `T` isn't registered.
#[cfg(feature = "tokio")]
#[cfg(any(doc, feature = "tokio"))]
async fn new(registry: &Registry) -> Self {
Self {
inner: registry.get_transient::<T>().await.expect(
Expand Down Expand Up @@ -202,7 +202,7 @@ impl<T: Registerable> Dep for Singleton<T> {
///
/// # Panic
/// This function panics if the `T` isn't registered.
#[cfg(not(feature = "tokio"))]
#[cfg(any(doc, not(feature = "tokio")))]
fn new(registry: &Registry) -> Self {
Self {
inner: registry.get_singleton::<T>().expect(
Expand All @@ -216,7 +216,7 @@ impl<T: Registerable> Dep for Singleton<T> {
///
/// # Panic
/// This function panics if the `T` isn't registered.
#[cfg(feature = "tokio")]
#[cfg(any(doc, feature = "tokio"))]
async fn new(registry: &Registry) -> Self {
Self {
inner: registry.get_singleton::<T>().await.expect(
Expand Down
1 change: 1 addition & 0 deletions ferrunix-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//!
//! [`ferrunix`]: https://crates.io/crates/ferrunix
//! [`ferrunix-core`]: https://crates.io/crates/ferrunix-core
// #![doc(test(attr(cfg(not(feature = "tokio")))))]

pub mod dependencies;
pub mod dependency_builder;
Expand Down
1 change: 1 addition & 0 deletions ferrunix-core/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl RegistrationFunc {
///
/// # Example
/// ```no_run
/// # #![cfg(not(feature = "tokio"))]
/// # use ferrunix_core::*;
/// # use ferrunix_core::registration::*;
/// #[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions ferrunix-core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Registry {
///
/// This is the constructor for the global registry that can be acquired
/// with [`Registry::global`].
#[cfg(not(feature = "tokio"))]
#[cfg(any(doc, not(feature = "tokio")))]
#[must_use]
pub fn autoregistered() -> Self {
let registry = Self::empty();
Expand All @@ -54,7 +54,7 @@ impl Registry {
///
/// This is the constructor for the global registry that can be acquired
/// with [`Registry::global`].
#[cfg(feature = "tokio")]
#[cfg(any(doc, feature = "tokio"))]
#[must_use]
pub async fn autoregistered() -> Self {
let registry = Self::empty();
Expand Down
3 changes: 3 additions & 0 deletions ferrunix-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ darling = "0.20"

[dev-dependencies]
thiserror = "1"

[package.metadata."docs.rs"]
all-features = true
3 changes: 3 additions & 0 deletions ferrunix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ ferrunix-macros = { path = "../ferrunix-macros", optional = true, version = "=0.
[dev-dependencies]
thiserror = "1"
tokio = { version = "1", features = ["full"] }

# [package.metadata."docs.rs"]
# all-features = true
55 changes: 31 additions & 24 deletions xtask/src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,37 @@ pub(super) fn run() -> Result<()> {
exit(1);
}

cmd!(sh, "cargo test -p ferrunix --no-default-features").run()?;
cmd!(sh, "cargo test -p ferrunix --no-default-features -F derive").run()?;
cmd!(
sh,
"cargo test -p ferrunix --no-default-features -F derive,multithread"
)
.run()?;
cmd!(sh, "cargo test -p ferrunix-core --no-default-features").run()?;
cmd!(
sh,
"cargo test -p ferrunix-core --no-default-features -F multithread"
)
.run()?;
cmd!(sh, "cargo test -p ferrunix-macros --no-default-features").run()?;
cmd!(
sh,
"cargo test -p ferrunix-macros --no-default-features -F multithread"
)
.run()?;
cmd!(
sh,
"cargo test -p ferrunix-macros --no-default-features -F multithread,development"
)
.run()?;
let test_matrix = [
("ferrunix", ""),
("ferrunix", "derive"),
("ferrunix", "multithread"),
("ferrunix", "tokio"),
("ferrunix", "derive,multithread"),
("ferrunix", "derive,tokio"),
("ferrunix-core", ""),
("ferrunix-core", "multithread"),
("ferrunix-core", "tokio"),
("ferrunix-macros", ""),
("ferrunix-macros", "multithread"),
("ferrunix-macros", "development"),
("ferrunix-macros", "development,multithread"),
];

let testrunner = &["test"];
for (proj, features) in test_matrix {
if features.is_empty() {
cmd!(sh, "cargo {testrunner...} -p {proj} --no-default-features")
.run()?;
continue;
}

cmd!(
sh,
"cargo {testrunner...} -p {proj} --no-default-features -F {features}"
)
.run()?;
}

cmd!(sh, "cargo test --all").run()?;
cmd!(sh, "cargo clippy --tests --workspace").run()?;

Expand Down

0 comments on commit d390a1c

Please sign in to comment.