diff --git a/genetic-rs-common/Cargo.toml b/genetic-rs-common/Cargo.toml index f497444..2290042 100644 --- a/genetic-rs-common/Cargo.toml +++ b/genetic-rs-common/Cargo.toml @@ -23,9 +23,12 @@ rayon = ["dep:rayon"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [package.metadata.docs.rs] -features = ["crossover", "speciation"] +all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints.rust] +unexpected_cfgs = { level = "allow", check-cfg = ["cfg(docsrs)"] } + [dependencies] itertools = { version = "0.14.0", optional = true } rand = { version = "0.10.0", optional = true } diff --git a/genetic-rs-common/src/builtin/eliminator.rs b/genetic-rs-common/src/builtin/eliminator.rs index a64bcb7..7eef8e0 100644 --- a/genetic-rs-common/src/builtin/eliminator.rs +++ b/genetic-rs-common/src/builtin/eliminator.rs @@ -285,7 +285,6 @@ mod knockout { use super::*; /// A distinct type to help clarify the result of a knockout function. - #[cfg_attr(docsrs, doc(cfg(feature = "knockout")))] #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum KnockoutWinner { /// The first genome parameter won. @@ -325,7 +324,6 @@ mod knockout { } /// A function that pits two genomes against each other and determines a winner. - #[cfg_attr(docsrs, doc(cfg(feature = "knockout")))] pub trait KnockoutFn { /// Tests the genomes to figure out who wins. fn knockout(&self, a: &G, b: &G) -> KnockoutWinner; @@ -383,7 +381,6 @@ mod knockout { impl + Send + Sync> FeatureBoundedKnockoutFn for T {} /// The action a knockout eliminator should take if the number of genomes is odd. - #[cfg_attr(docsrs, doc(cfg(feature = "knockout")))] pub enum ActionIfOdd { /// Always expect an even number, crash if odd. Panic, @@ -415,7 +412,6 @@ mod knockout { } /// Eliminator that pits genomes against each other and eliminates the weaker ones. - #[cfg_attr(docsrs, doc(cfg(feature = "knockout")))] pub struct KnockoutEliminator> { /// The function that determines the winner of a pair of genomes. pub knockout_fn: K, diff --git a/genetic-rs-common/src/builtin/repopulator.rs b/genetic-rs-common/src/builtin/repopulator.rs index 2ddd7ac..416c30b 100644 --- a/genetic-rs-common/src/builtin/repopulator.rs +++ b/genetic-rs-common/src/builtin/repopulator.rs @@ -91,7 +91,6 @@ mod crossover { use super::*; /// Used in crossover-reproducing [`Repopulator`]s - #[cfg_attr(docsrs, doc(cfg(feature = "crossover")))] pub trait Crossover: Clone { /// Simulation-wide context required for this crossover implementation. type Context; @@ -107,7 +106,6 @@ mod crossover { } /// Repopulator that uses crossover reproduction to create new genomes. - #[cfg_attr(docsrs, doc(cfg(feature = "crossover")))] pub struct CrossoverRepopulator { /// The mutation rate to use when mutating genomes. 0.0 - 1.0 pub mutation_rate: f32, @@ -166,7 +164,6 @@ mod speciation { use super::*; /// Used in speciated crossover nextgens. Allows for genomes to avoid crossover with ones that are too different. - #[cfg_attr(docsrs, doc(cfg(feature = "speciation")))] pub trait Speciated { /// The type used to distinguish /// one genome's species from another. @@ -177,7 +174,6 @@ mod speciation { } /// Repopulator that uses crossover reproduction to create new genomes, but only between genomes of the same species. - #[cfg_attr(docsrs, doc(cfg(feature = "speciation")))] pub struct SpeciatedCrossoverRepopulator { /// The inner crossover repopulator. This holds the settings for crossover operations, /// but may also be called if [`allow_emergency_repr`][Self::allow_emergency_repr] is `true`. diff --git a/genetic-rs-common/src/lib.rs b/genetic-rs-common/src/lib.rs index 4b19a70..751c3e2 100644 --- a/genetic-rs-common/src/lib.rs +++ b/genetic-rs-common/src/lib.rs @@ -1,11 +1,10 @@ #![warn(missing_docs)] #![allow(clippy::needless_doctest_main)] -#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] //! The crate containing the core traits and structs of genetic-rs. /// Built-in nextgen functions and traits to go with them. -#[cfg_attr(docsrs, doc(cfg(feature = "builtin")))] #[cfg(feature = "builtin")] pub mod builtin; @@ -112,7 +111,6 @@ where /// Helper trait used in the generation of random starting populations #[cfg(feature = "genrand")] -#[cfg_attr(docsrs, doc(cfg(feature = "genrand")))] pub trait GenerateRandom { /// Create a completely random instance of the genome fn gen_random(rng: &mut impl rand::Rng) -> Self; @@ -120,7 +118,6 @@ pub trait GenerateRandom { /// Blanket trait used on collections that contain objects implementing [`GenerateRandom`] #[cfg(feature = "genrand")] -#[cfg_attr(docsrs, doc(cfg(feature = "genrand")))] pub trait GenerateRandomCollection where T: GenerateRandom, diff --git a/genetic-rs-macros/Cargo.toml b/genetic-rs-macros/Cargo.toml index 576484c..46347fd 100644 --- a/genetic-rs-macros/Cargo.toml +++ b/genetic-rs-macros/Cargo.toml @@ -19,7 +19,12 @@ default = ["genrand", "crossover"] crossover = ["genetic-rs-common/crossover"] genrand = [] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unexpected_cfgs = { level = "allow", check-cfg = ["cfg(docsrs)"] } [dependencies] darling = "0.23.0" diff --git a/genetic-rs/Cargo.toml b/genetic-rs/Cargo.toml index c80452b..0dc0fad 100644 --- a/genetic-rs/Cargo.toml +++ b/genetic-rs/Cargo.toml @@ -25,8 +25,12 @@ derive = ["dep:genetic-rs-macros", "builtin"] genetic-rs-common = { path = "../genetic-rs-common", version = "1.2.1", default-features = false } genetic-rs-macros = { path = "../genetic-rs-macros", version = "1.2.1", optional = true } +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [lints.rust] -unexpected_cfgs = { level = "allow", check-cfg = ["cfg(publish)"] } +unexpected_cfgs = { level = "allow", check-cfg = ["cfg(publish)", "cfg(docsrs)"] } [dev-dependencies] rand = "0.10.0" diff --git a/genetic-rs/src/lib.rs b/genetic-rs/src/lib.rs index f609442..1deed4f 100644 --- a/genetic-rs/src/lib.rs +++ b/genetic-rs/src/lib.rs @@ -1,4 +1,5 @@ #![allow(clippy::needless_doctest_main)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(publish, doc = include_str!(env!("CARGO_PKG_README")))] #![cfg_attr(not(publish), doc = include_str!(concat!("../", env!("CARGO_PKG_README"))))]