Skip to content

Commit 26a2eff

Browse files
committed
Fix documentation of re-exports
1 parent d4df901 commit 26a2eff

File tree

10 files changed

+19
-18
lines changed

10 files changed

+19
-18
lines changed

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ref_as_ptr = "warn"
4949
unsafe_op_in_unsafe_fn = "warn"
5050
missing_docs = "warn"
5151
unsafe_code = "deny"
52+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
5253

5354
[lints]
5455
workspace = true
@@ -3363,6 +3364,11 @@ lto = "fat"
33633364
panic = "abort"
33643365

33653366
[package.metadata.docs.rs]
3367+
# This cfg is needed so that #[doc(fake_variadic)] is correctly propagated for
3368+
# impls for re-exported traits. See https://github.com/rust-lang/cargo/issues/8811
3369+
# for details on why this is needed. Since dependencies don't expect to be built
3370+
# with `--cfg docsrs` (and thus fail to compile) we use a different cfg.
3371+
rustc-args = ["--cfg docsrs_dep"]
33663372
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
33673373
all-features = true
33683374
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

crates/bevy_app/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
22
#![allow(internal_features)]
3-
#![cfg_attr(docsrs, feature(doc_auto_cfg, rustdoc_internals))]
3+
#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))]
44
#![forbid(unsafe_code)]
55
#![doc(
66
html_logo_url = "https://bevyengine.org/assets/icon.png",

crates/bevy_dylib/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
2-
#![allow(internal_features)]
3-
#![cfg_attr(docsrs, feature(doc_auto_cfg, rustdoc_internals))]
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
42
#![doc(
53
html_logo_url = "https://bevyengine.org/assets/icon.png",
64
html_favicon_url = "https://bevyengine.org/assets/icon.png"

crates/bevy_ecs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![doc = include_str!("../README.md")]
44
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
55
#![allow(internal_features)]
6-
#![cfg_attr(docsrs, feature(doc_auto_cfg, rustdoc_internals))]
6+
#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))]
77
#![allow(unsafe_code)]
88
#![doc(
99
html_logo_url = "https://bevyengine.org/assets/icon.png",

crates/bevy_internal/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
2-
#![allow(internal_features)]
3-
#![cfg_attr(docsrs, feature(doc_auto_cfg, rustdoc_internals))]
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
42
#![forbid(unsafe_code)]
53
#![doc(
64
html_logo_url = "https://bevyengine.org/assets/icon.png",

crates/bevy_reflect/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![allow(missing_docs)]
33
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
44
#![allow(internal_features)]
5-
#![cfg_attr(docsrs, feature(doc_auto_cfg, rustdoc_internals))]
5+
#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))]
66
#![doc(
77
html_logo_url = "https://bevyengine.org/assets/icon.png",
88
html_favicon_url = "https://bevyengine.org/assets/icon.png"

crates/bevy_render/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![allow(unsafe_code)]
44
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
55
#![allow(internal_features)]
6-
#![cfg_attr(docsrs, feature(doc_auto_cfg, rustdoc_internals))]
6+
#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))]
77
#![doc(
88
html_logo_url = "https://bevyengine.org/assets/icon.png",
99
html_favicon_url = "https://bevyengine.org/assets/icon.png"

crates/bevy_state/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
3030
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
3131
#![allow(internal_features)]
32-
#![cfg_attr(docsrs, feature(rustdoc_internals))]
32+
#![cfg_attr(any(docsrs, docsrs_dep), feature(rustdoc_internals))]
3333

3434
#[cfg(feature = "bevy_app")]
3535
/// Provides [`App`](bevy_app::App) and [`SubApp`](bevy_app::SubApp) with state installation methods

crates/bevy_utils/macros/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl Parse for AllTuples {
134134
/// ```
135135
/// // `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
136136
/// #![allow(internal_features)]
137-
/// #![cfg_attr(docsrs, feature(doc_auto_cfg, rustdoc_internals))]
137+
/// #![cfg_attr(any(docsrs, docsrs_dep), feature(rustdoc_internals))]
138138
/// ```
139139
///
140140
/// ```
@@ -280,6 +280,7 @@ fn choose_ident_tuples<'a>(
280280
}
281281

282282
fn fake_variadic_attrs(len: usize, i: usize) -> TokenStream2 {
283+
let cfg = quote! { any(docsrs, docsrs_dep) };
283284
match i {
284285
// An empty tuple (i.e. the unit type) is still documented separately,
285286
// so no `#[doc(hidden)]` here.
@@ -291,10 +292,10 @@ fn fake_variadic_attrs(len: usize, i: usize) -> TokenStream2 {
291292
Span2::call_site(),
292293
);
293294
quote! {
294-
#[cfg_attr(docsrs, doc(fake_variadic))]
295-
#[cfg_attr(docsrs, doc = #doc)]
295+
#[cfg_attr(#cfg, doc(fake_variadic))]
296+
#[cfg_attr(#cfg, doc = #doc)]
296297
}
297298
}
298-
_ => quote! { #[cfg_attr(docsrs, doc(hidden))] },
299+
_ => quote! { #[cfg_attr(#cfg, doc(hidden))] },
299300
}
300301
}

src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![allow(clippy::single_component_path_imports)]
2-
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
3-
#![allow(internal_features)]
4-
#![cfg_attr(docsrs, feature(doc_auto_cfg, rustdoc_internals))]
2+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
53

64
//! [![Bevy Logo](https://bevyengine.org/assets/bevy_logo_docs.svg)](https://bevyengine.org)
75
//!

0 commit comments

Comments
 (0)