Skip to content

Commit ed35129

Browse files
authored
Use #[doc(fake_variadic)] on StableInterpolate (#15933)
This is a follow-up to #15931 that adds `#[doc(fake_variadic)]` for improved docs output :)
1 parent 5157fef commit ed35129

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

crates/bevy_math/src/common_traits.rs

+23
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,31 @@ impl StableInterpolate for Dir3A {
310310
}
311311
}
312312

313+
// If you're confused about how #[doc(fake_variadic)] works,
314+
// then the `all_tuples` macro is nicely documented (it can be found in the `bevy_utils` crate).
315+
// tl;dr: `#[doc(fake_variadic)]` goes on the impl of tuple length one.
316+
// the others have to be hidden using `#[doc(hidden)]`.
313317
macro_rules! impl_stable_interpolate_tuple {
318+
(($T:ident, $n:tt)) => {
319+
impl_stable_interpolate_tuple! {
320+
@impl
321+
#[cfg_attr(any(docsrs, docsrs_dep), doc(fake_variadic))]
322+
#[cfg_attr(
323+
any(docsrs, docsrs_dep),
324+
doc = "This trait is implemented for tuples up to 11 items long."
325+
)]
326+
($T, $n)
327+
}
328+
};
314329
($(($T:ident, $n:tt)),*) => {
330+
impl_stable_interpolate_tuple! {
331+
@impl
332+
#[cfg_attr(any(docsrs, docsrs_dep), doc(hidden))]
333+
$(($T, $n)),*
334+
}
335+
};
336+
(@impl $(#[$($meta:meta)*])* $(($T:ident, $n:tt)),*) => {
337+
$(#[$($meta)*])*
315338
impl<$($T: StableInterpolate),*> StableInterpolate for ($($T,)*) {
316339
fn interpolate_stable(&self, other: &Self, t: f32) -> Self {
317340
(

crates/bevy_math/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
21
#![forbid(unsafe_code)]
2+
#![allow(internal_features)]
3+
#![cfg_attr(any(docsrs, docsrs_dep), feature(rustdoc_internals))]
4+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
35
#![doc(
46
html_logo_url = "https://bevyengine.org/assets/icon.png",
57
html_favicon_url = "https://bevyengine.org/assets/icon.png"

0 commit comments

Comments
 (0)