From ed351294ec75b43dae9fc492d21d3fb91d3572f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tau=20G=C3=A4rtli?= Date: Wed, 16 Oct 2024 01:40:42 +0200 Subject: [PATCH] Use `#[doc(fake_variadic)]` on `StableInterpolate` (#15933) This is a follow-up to #15931 that adds `#[doc(fake_variadic)]` for improved docs output :) --- crates/bevy_math/src/common_traits.rs | 23 +++++++++++++++++++++++ crates/bevy_math/src/lib.rs | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/bevy_math/src/common_traits.rs b/crates/bevy_math/src/common_traits.rs index a6aeb04683..a747ecb42c 100644 --- a/crates/bevy_math/src/common_traits.rs +++ b/crates/bevy_math/src/common_traits.rs @@ -310,8 +310,31 @@ impl StableInterpolate for Dir3A { } } +// If you're confused about how #[doc(fake_variadic)] works, +// then the `all_tuples` macro is nicely documented (it can be found in the `bevy_utils` crate). +// tl;dr: `#[doc(fake_variadic)]` goes on the impl of tuple length one. +// the others have to be hidden using `#[doc(hidden)]`. macro_rules! impl_stable_interpolate_tuple { + (($T:ident, $n:tt)) => { + impl_stable_interpolate_tuple! { + @impl + #[cfg_attr(any(docsrs, docsrs_dep), doc(fake_variadic))] + #[cfg_attr( + any(docsrs, docsrs_dep), + doc = "This trait is implemented for tuples up to 11 items long." + )] + ($T, $n) + } + }; ($(($T:ident, $n:tt)),*) => { + impl_stable_interpolate_tuple! { + @impl + #[cfg_attr(any(docsrs, docsrs_dep), doc(hidden))] + $(($T, $n)),* + } + }; + (@impl $(#[$($meta:meta)*])* $(($T:ident, $n:tt)),*) => { + $(#[$($meta)*])* impl<$($T: StableInterpolate),*> StableInterpolate for ($($T,)*) { fn interpolate_stable(&self, other: &Self, t: f32) -> Self { ( diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index 46062fc852..0f6caa30cf 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -1,5 +1,7 @@ -#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![forbid(unsafe_code)] +#![allow(internal_features)] +#![cfg_attr(any(docsrs, docsrs_dep), feature(rustdoc_internals))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc( html_logo_url = "https://bevyengine.org/assets/icon.png", html_favicon_url = "https://bevyengine.org/assets/icon.png"