Skip to content

Commit 72c51cd

Browse files
authored
Make feature(doc_auto_cfg) work (#12642)
# Objective - In #12366 `![cfg_attr(docsrs, feature(doc_auto_cfg))] `was added. But to apply it it needs `--cfg=docsrs` in rustdoc-args. ## Solution - Apply `--cfg=docsrs` to all crates and CI. I also added `[package.metadata.docs.rs]` to all crates to avoid adding code behind a feature and forget adding the metadata. Before: ![Screenshot 2024-03-22 at 00 51 57](https://github.com/bevyengine/bevy/assets/104745335/6a9dfdaa-8710-4784-852b-5f9b74e3522c) After: ![Screenshot 2024-03-22 at 00 51 32](https://github.com/bevyengine/bevy/assets/104745335/c5bd6d8e-8ddb-45b3-b844-5ecf9f88961c)
1 parent d836ece commit 72c51cd

File tree

91 files changed

+223
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+223
-38
lines changed

.github/workflows/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ jobs:
4949
echo "<meta name=\"robots\" content=\"noindex\">" > header.html
5050
5151
- name: Build docs
52+
env:
53+
# needs to be in sync with [package.metadata.docs.rs]
54+
RUSTDOCFLAGS: -Zunstable-options --cfg=docsrs
5255
run: cargo doc --all-features --no-deps -p bevy -Zunstable-options -Zrustdoc-scrape-examples
5356

5457
# This adds the following:

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2821,5 +2821,6 @@ lto = "fat"
28212821
panic = "abort"
28222822

28232823
[package.metadata.docs.rs]
2824-
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
2824+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
28252825
all-features = true
2826+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

crates/bevy_a11y/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ accesskit = "0.12"
1818

1919
[lints]
2020
workspace = true
21+
22+
[package.metadata.docs.rs]
23+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
24+
all-features = true

crates/bevy_a11y/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//! Accessibility for Bevy
2-
31
#![forbid(unsafe_code)]
2+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3+
4+
//! Accessibility for Bevy
45
56
use std::sync::{
67
atomic::{AtomicBool, Ordering},

crates/bevy_animation/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ uuid = { version = "1.7", features = ["v4"] }
4040

4141
[lints]
4242
workspace = true
43+
44+
[package.metadata.docs.rs]
45+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
46+
all-features = true

crates/bevy_animation/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! Animation for the game engine Bevy
24
35
mod animatable;

crates/bevy_app/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ web-sys = { version = "0.3", features = ["Window"] }
3636
workspace = true
3737

3838
[package.metadata.docs.rs]
39+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
3940
all-features = true

crates/bevy_app/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//! This crate is about everything concerning the highest-level, application layer of a Bevy app.
21
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
32

3+
//! This crate is about everything concerning the highest-level, application layer of a Bevy app.
4+
45
mod app;
56
mod main_schedule;
67
mod plugin;

crates/bevy_asset/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
6161
workspace = true
6262

6363
[package.metadata.docs.rs]
64+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
6465
all-features = true

crates/bevy_asset/macros/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ quote = "1.0"
2020

2121
[lints]
2222
workspace = true
23+
24+
[package.metadata.docs.rs]
25+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
26+
all-features = true

crates/bevy_asset/macros/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// FIXME(3492): remove once docs are ready
22
#![allow(missing_docs)]
3+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
34

45
use bevy_macro_utils::BevyManifest;
56
use proc_macro::{Span, TokenStream};

crates/bevy_audio/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ android_shared_stdcxx = ["cpal/oboe-shared-stdcxx"]
5252
workspace = true
5353

5454
[package.metadata.docs.rs]
55+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
5556
all-features = true

crates/bevy_audio/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![forbid(unsafe_code)]
2+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3+
14
//! Audio support for the game engine Bevy
25
//!
36
//! ```no_run
@@ -19,8 +22,6 @@
1922
//! });
2023
//! }
2124
//! ```
22-
#![forbid(unsafe_code)]
23-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2425
2526
mod audio;
2627
mod audio_output;

crates/bevy_color/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ encase = { version = "0.7", default-features = false }
2121

2222
[lints]
2323
workspace = true
24+
25+
[package.metadata.docs.rs]
26+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
27+
all-features = true

crates/bevy_color/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! Representations of colors in various color spaces.
24
//!
35
//! This crate provides a number of color representations, including:

crates/bevy_core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ crossbeam-channel = "0.5.0"
3737
workspace = true
3838

3939
[package.metadata.docs.rs]
40+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
4041
all-features = true

crates/bevy_core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//! This crate provides core functionality for Bevy Engine.
21
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
32

3+
//! This crate provides core functionality for Bevy Engine.
4+
45
mod name;
56
#[cfg(feature = "serialize")]
67
mod serde;

crates/bevy_core_pipeline/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ nonmax = "0.5"
4242
workspace = true
4343

4444
[package.metadata.docs.rs]
45+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
4546
all-features = true

crates/bevy_derive/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ syn = { version = "2.0", features = ["full"] }
1919

2020
[lints]
2121
workspace = true
22+
23+
[package.metadata.docs.rs]
24+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
25+
all-features = true

crates/bevy_derive/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// FIXME(3492): remove once docs are ready
22
#![allow(missing_docs)]
3+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
34

45
extern crate proc_macro;
56

crates/bevy_dev_tools/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ ron = { version = "0.8.0", optional = true }
4343
workspace = true
4444

4545
[package.metadata.docs.rs]
46+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
4647
all-features = true

crates/bevy_dev_tools/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! This crate provides additional utilities for the [Bevy game engine](https://bevyengine.org),
24
//! focused on improving developer experience.
3-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
45
56
use bevy_app::prelude::*;
67

crates/bevy_diagnostic/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ sysinfo = { version = "0.30.0", optional = true, default-features = false }
3838
workspace = true
3939

4040
[package.metadata.docs.rs]
41+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
4142
all-features = true

crates/bevy_dylib/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ bevy_internal = { path = "../bevy_internal", version = "0.14.0-dev", default-fea
1616

1717
[lints]
1818
workspace = true
19+
20+
[package.metadata.docs.rs]
21+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
22+
all-features = true

crates/bevy_dylib/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::single_component_path_imports)]
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
22

33
//! Forces dynamic linking of Bevy.
44
//!
@@ -51,4 +51,5 @@
5151
5252
// Force linking of the main bevy crate
5353
#[allow(unused_imports)]
54+
#[allow(clippy::single_component_path_imports)]
5455
use bevy_internal;

crates/bevy_dynamic_plugin/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ thiserror = "1.0"
1818

1919
[lints]
2020
workspace = true
21+
22+
[package.metadata.docs.rs]
23+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
24+
all-features = true

crates/bevy_dynamic_plugin/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! Bevy's dynamic plugin loading functionality.
24
//!
35
//! This crate allows loading dynamic libraries (`.dylib`, `.so`) that export a single

crates/bevy_ecs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ path = "examples/change_detection.rs"
5151
workspace = true
5252

5353
[package.metadata.docs.rs]
54+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
5455
all-features = true

crates/bevy_ecs/macros/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ proc-macro2 = "1.0"
1717

1818
[lints]
1919
workspace = true
20+
21+
[package.metadata.docs.rs]
22+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
23+
all-features = true

crates/bevy_ecs/macros/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// FIXME(3492): remove once docs are ready
22
#![allow(missing_docs)]
3+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
34

45
extern crate proc_macro;
56

crates/bevy_encase_derive/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ encase_derive_impl = "0.7"
1717

1818
[lints]
1919
workspace = true
20+
21+
[package.metadata.docs.rs]
22+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
23+
all-features = true

crates/bevy_encase_derive/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// FIXME(3492): remove once docs are ready
22
#![allow(missing_docs)]
3+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
34

45
use bevy_macro_utils::BevyManifest;
56
use encase_derive_impl::{implement, syn};

crates/bevy_gilrs/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ thiserror = "1.0"
2222

2323
[lints]
2424
workspace = true
25+
26+
[package.metadata.docs.rs]
27+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
28+
all-features = true

crates/bevy_gilrs/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! Systems and type definitions for gamepad handling in Bevy.
24
//!
35
//! This crate is built on top of [GilRs](gilrs), a library

crates/bevy_gizmos/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ bytemuck = "1.0"
3434
workspace = true
3535

3636
[package.metadata.docs.rs]
37+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
3738
all-features = true

crates/bevy_gizmos/macros/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ keywords = ["bevy"]
1111
[lib]
1212
proc-macro = true
1313

14-
[lints]
15-
workspace = true
1614

1715
[dependencies]
1816
bevy_macro_utils = { path = "../../bevy_macro_utils", version = "0.14.0-dev" }
1917

2018
syn = "2.0"
2119
proc-macro2 = "1.0"
2220
quote = "1.0"
21+
22+
[lints]
23+
workspace = true
24+
25+
[package.metadata.docs.rs]
26+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
27+
all-features = true

crates/bevy_gizmos/macros/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! Derive implementations for `bevy_gizmos`.
24
35
use bevy_macro_utils::BevyManifest;

crates/bevy_gizmos/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! This crate adds an immediate mode drawing api to Bevy for visual debugging.
24
//!
35
//! # Example
@@ -13,7 +15,6 @@
1315
//! ```
1416
//!
1517
//! See the documentation on [Gizmos](crate::gizmos::Gizmos) for more examples.
16-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
1718
1819
/// System set label for the systems handling the rendering of gizmos.
1920
#[derive(SystemSet, Clone, Debug, Hash, PartialEq, Eq)]

crates/bevy_gltf/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ smallvec = "1.11"
6060
workspace = true
6161

6262
[package.metadata.docs.rs]
63+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
6364
all-features = true

crates/bevy_gltf/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! Plugin providing an [`AssetLoader`](bevy_asset::AssetLoader) and type definitions
24
//! for loading glTF 2.0 (a standard 3D scene definition format) files in Bevy.
35
//!
46
//! The [glTF 2.0 specification](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html) defines the format of the glTF files.
5-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
67
78
#[cfg(feature = "bevy_animation")]
89
use bevy_animation::AnimationClip;

crates/bevy_hierarchy/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ smallvec = { version = "1.11", features = ["union", "const_generics"] }
3131
workspace = true
3232

3333
[package.metadata.docs.rs]
34+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
3435
all-features = true

crates/bevy_hierarchy/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! Parent-child relationships for Bevy entities.
24
//!
35
//! You should use the tools in this crate
@@ -44,7 +46,6 @@
4446
//! [plugin]: HierarchyPlugin
4547
//! [query extension methods]: HierarchyQueryExt
4648
//! [world]: BuildWorldChildren
47-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
4849
4950
mod components;
5051
pub use components::*;

crates/bevy_input/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ smol_str = "0.2"
3232
workspace = true
3333

3434
[package.metadata.docs.rs]
35+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
3536
all-features = true

crates/bevy_input/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! Input functionality for the [Bevy game engine](https://bevyengine.org/).
24
//!
35
//! # Supported input devices
46
//!
57
//! `bevy` currently supports keyboard, mouse, gamepad, and touch inputs.
6-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
78
89
mod axis;
910
mod button_input;

crates/bevy_internal/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,7 @@ bevy_dev_tools = { path = "../bevy_dev_tools", optional = true, version = "0.14.
207207

208208
[lints]
209209
workspace = true
210+
211+
[package.metadata.docs.rs]
212+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
213+
all-features = true

crates/bevy_internal/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! This module is separated into its own crate to enable simple dynamic linking for Bevy, and should not be used directly
24
35
/// `use bevy::prelude::*;` to import common components, bundles, and plugins.

crates/bevy_log/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ tracing-wasm = "0.2.1"
4040
workspace = true
4141

4242
[package.metadata.docs.rs]
43+
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
4344
all-features = true

crates/bevy_log/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2+
13
//! This crate provides logging functions and configuration for [Bevy](https://bevyengine.org)
24
//! apps, and automatically configures platform specific log handlers (i.e. WASM or Android).
35
//!
@@ -9,7 +11,6 @@
911
//!
1012
//! For more fine-tuned control over logging behavior, set up the [`LogPlugin`] or
1113
//! `DefaultPlugins` during app initialization.
12-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
1314
1415
#[cfg(feature = "trace")]
1516
use std::panic;

0 commit comments

Comments
 (0)