Skip to content

Commit 0256dac

Browse files
authored
Fix some doc warnings (#12961)
# Objective - Fix some doc warnings - Add doc-scrape-examples to all examples Moved from #12692 I run `cargo +nightly doc --workspace --all-features --no-deps -Zunstable-options -Zrustdoc-scrape-examples` <details> ``` warning: public documentation for `GzAssetLoaderError` links to private item `GzAssetLoader` --> examples/asset/asset_decompression.rs:24:47 | 24 | /// Possible errors that can be produced by [`GzAssetLoader`] | ^^^^^^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: `bevy` (example "asset_decompression") generated 1 warning warning: unresolved link to `shape::Quad` --> examples/2d/mesh2d.rs:3:15 | 3 | //! [`Quad`]: shape::Quad | ^^^^^^^^^^^ no item named `shape` in scope | = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default warning: `bevy` (example "mesh2d") generated 1 warning warning: unresolved link to `WorldQuery` --> examples/ecs/custom_query_param.rs:1:49 | 1 | //! This example illustrates the usage of the [`WorldQuery`] derive macro, which allows | ^^^^^^^^^^ no item named `WorldQuery` in scope | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default warning: `bevy` (example "custom_query_param") generated 1 warning warning: unresolved link to `shape::Quad` --> examples/2d/mesh2d_vertex_color_texture.rs:4:15 | 4 | //! [`Quad`]: shape::Quad | ^^^^^^^^^^^ no item named `shape` in scope | = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default warning: `bevy` (example "mesh2d_vertex_color_texture") generated 1 warning warning: public documentation for `TextPlugin` links to private item `CoolText` --> examples/asset/processing/asset_processing.rs:48:9 | 48 | /// * [`CoolText`]: a custom RON text format that supports dependencies and embedded dependencies | ^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: public documentation for `TextPlugin` links to private item `Text` --> examples/asset/processing/asset_processing.rs:49:9 | 49 | /// * [`Text`]: a "normal" plain text file | ^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` warning: public documentation for `TextPlugin` links to private item `CoolText` --> examples/asset/processing/asset_processing.rs:51:57 | 51 | /// It also defines an asset processor that will load [`CoolText`], resolve embedded dependenc... | ^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` warning: `bevy` (example "asset_processing") generated 3 warnings warning: public documentation for `CustomAssetLoaderError` links to private item `CustomAssetLoader` --> examples/asset/custom_asset.rs:20:47 | 20 | /// Possible errors that can be produced by [`CustomAssetLoader`] | ^^^^^^^^^^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: public documentation for `BlobAssetLoaderError` links to private item `CustomAssetLoader` --> examples/asset/custom_asset.rs:61:47 | 61 | /// Possible errors that can be produced by [`CustomAssetLoader`] | ^^^^^^^^^^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` ``` ``` warning: `bevy` (example "mesh2d") generated 1 warning warning: public documentation for `log_layers_ecs` links to private item `update_subscriber` --> examples/app/log_layers_ecs.rs:6:18 | 6 | //! Inside the [`update_subscriber`] function we will create a [`mpsc::Sender`] and a [`mpsc::R... | ^^^^^^^^^^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default warning: unresolved link to `AdvancedLayer` --> examples/app/log_layers_ecs.rs:7:72 | 7 | ... will go into the [`AdvancedLayer`] and the [`Receiver`](mpsc::Receiver) will | ^^^^^^^^^^^^^ no item named `AdvancedLayer` in scope | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default warning: unresolved link to `LogEvents` --> examples/app/log_layers_ecs.rs:8:42 | 8 | //! go into a non-send resource called [`LogEvents`] (It has to be non-send because [`Receiver`... | ^^^^^^^^^ no item named `LogEvents` in scope | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: public documentation for `log_layers_ecs` links to private item `transfer_log_events` --> examples/app/log_layers_ecs.rs:9:30 | 9 | //! From there we will use [`transfer_log_events`] to transfer log events from [`LogEvents`] to... | ^^^^^^^^^^^^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` warning: unresolved link to `LogEvents` --> examples/app/log_layers_ecs.rs:9:82 | 9 | ...nsfer log events from [`LogEvents`] to an ECS event called [`LogEvent`]. | ^^^^^^^^^ no item named `LogEvents` in scope | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: public documentation for `log_layers_ecs` links to private item `LogEvent` --> examples/app/log_layers_ecs.rs:9:119 | 9 | ...nts`] to an ECS event called [`LogEvent`]. | ^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` warning: public documentation for `log_layers_ecs` links to private item `LogEvent` --> examples/app/log_layers_ecs.rs:11:49 | 11 | //! Finally, after all that we can access the [`LogEvent`] event from our systems and use it. | ^^^^^^^^ this item is private | = note: this link will resolve properly if you pass `--document-private-items` ``` <details/>
1 parent 7a9a459 commit 0256dac

8 files changed

+33
-24
lines changed

Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ wasm = true
380380
[[example]]
381381
name = "2d_viewport_to_world"
382382
path = "examples/2d/2d_viewport_to_world.rs"
383+
doc-scrape-examples = true
383384

384385
[package.metadata.example.2d_viewport_to_world]
385386
name = "2D Viewport To World"
@@ -489,6 +490,7 @@ wasm = true
489490
[[example]]
490491
name = "sprite_tile"
491492
path = "examples/2d/sprite_tile.rs"
493+
doc-scrape-examples = true
492494

493495
[package.metadata.example.sprite_tile]
494496
name = "Sprite Tile"
@@ -499,6 +501,7 @@ wasm = true
499501
[[example]]
500502
name = "sprite_slice"
501503
path = "examples/2d/sprite_slice.rs"
504+
doc-scrape-examples = true
502505

503506
[package.metadata.example.sprite_slice]
504507
name = "Sprite Slice"
@@ -542,6 +545,7 @@ wasm = true
542545
[[example]]
543546
name = "pixel_grid_snap"
544547
path = "examples/2d/pixel_grid_snap.rs"
548+
doc-scrape-examples = true
545549

546550
[package.metadata.example.pixel_grid_snap]
547551
name = "Pixel Grid Snapping"
@@ -729,6 +733,7 @@ wasm = true
729733
[[example]]
730734
name = "deferred_rendering"
731735
path = "examples/3d/deferred_rendering.rs"
736+
doc-scrape-examples = true
732737

733738
[package.metadata.example.deferred_rendering]
734739
name = "Deferred Rendering"
@@ -893,6 +898,7 @@ wasm = true
893898
[[example]]
894899
name = "transmission"
895900
path = "examples/3d/transmission.rs"
901+
doc-scrape-examples = true
896902

897903
[package.metadata.example.transmission]
898904
name = "Transmission"
@@ -1145,6 +1151,7 @@ wasm = true
11451151
[[example]]
11461152
name = "log_layers"
11471153
path = "examples/app/log_layers.rs"
1154+
doc-scrape-examples = true
11481155

11491156
[package.metadata.example.log_layers]
11501157
name = "Log layers"
@@ -1155,6 +1162,7 @@ wasm = false
11551162
[[example]]
11561163
name = "log_layers_ecs"
11571164
path = "examples/app/log_layers_ecs.rs"
1165+
doc-scrape-examples = true
11581166

11591167
[package.metadata.example.log_layers_ecs]
11601168
name = "Advanced log layers"
@@ -1423,6 +1431,7 @@ wasm = true
14231431
[[example]]
14241432
name = "pitch"
14251433
path = "examples/audio/pitch.rs"
1434+
doc-scrape-examples = true
14261435

14271436
[package.metadata.example.pitch]
14281437
name = "Pitch"
@@ -1595,6 +1604,7 @@ wasm = true
15951604
[[example]]
15961605
name = "one_shot_systems"
15971606
path = "examples/ecs/one_shot_systems.rs"
1607+
doc-scrape-examples = true
15981608

15991609
[package.metadata.example.one_shot_systems]
16001610
name = "One Shot Systems"
@@ -1706,6 +1716,7 @@ wasm = false
17061716
[[example]]
17071717
name = "time"
17081718
path = "examples/time/time.rs"
1719+
doc-scrape-examples = true
17091720

17101721
[package.metadata.example.time]
17111722
name = "Time handling"
@@ -1716,6 +1727,7 @@ wasm = false
17161727
[[example]]
17171728
name = "virtual_time"
17181729
path = "examples/time/virtual_time.rs"
1730+
doc-scrape-examples = true
17191731

17201732
[package.metadata.example.virtual_time]
17211733
name = "Virtual time"
@@ -2072,6 +2084,7 @@ wasm = true
20722084
[[example]]
20732085
name = "extended_material"
20742086
path = "examples/shader/extended_material.rs"
2087+
doc-scrape-examples = true
20752088

20762089
[package.metadata.example.extended_material]
20772090
name = "Extended Material"

examples/2d/mesh2d.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Shows how to render a polygonal [`Mesh`], generated from a [`Quad`] primitive, in a 2D scene.
2-
//!
3-
//! [`Quad`]: shape::Quad
1+
//! Shows how to render a polygonal [`Mesh`], generated from a [`Rectangle`] primitive, in a 2D scene.
42
53
use bevy::{color::palettes::basic::PURPLE, prelude::*, sprite::MaterialMesh2dBundle};
64

examples/2d/mesh2d_vertex_color_texture.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
//! Shows how to render a polygonal [`Mesh`], generated from a [`Quad`] primitive, in a 2D scene.
1+
//! Shows how to render a polygonal [`Mesh`], generated from a [`Rectangle`] primitive, in a 2D scene.
22
//! Adds a texture and colored vertices, giving per-vertex tinting.
3-
//!
4-
//! [`Quad`]: shape::Quad
53
64
use bevy::{
75
prelude::*,

examples/app/log_layers_ecs.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
//! The way we will do this is via a [`mpsc`] channel. [`mpsc`] channels allow 2 unrelated
44
//! parts of the program to communicate (in this case, [`Layer`]s and Bevy's ECS).
55
//!
6-
//! Inside the [`update_subscriber`] function we will create a [`mpsc::Sender`] and a [`mpsc::Receiver`] from a
7-
//! [`mpsc::channel`]. The [`Sender`](mpsc::Sender) will go into the [`AdvancedLayer`] and the [`Receiver`](mpsc::Receiver) will
8-
//! go into a non-send resource called [`LogEvents`] (It has to be non-send because [`Receiver`](mpsc::Receiver) is [`!Sync`](Sync)).
9-
//! From there we will use [`transfer_log_events`] to transfer log events from [`LogEvents`] to an ECS event called [`LogEvent`].
6+
//! Inside the `update_subscriber` function we will create a [`mpsc::Sender`] and a [`mpsc::Receiver`] from a
7+
//! [`mpsc::channel`]. The [`Sender`](mpsc::Sender) will go into the `AdvancedLayer` and the [`Receiver`](mpsc::Receiver) will
8+
//! go into a non-send resource called `LogEvents` (It has to be non-send because [`Receiver`](mpsc::Receiver) is [`!Sync`](Sync)).
9+
//! From there we will use `transfer_log_events` to transfer log events from `LogEvents` to an ECS event called `LogEvent`.
1010
//!
11-
//! Finally, after all that we can access the [`LogEvent`] event from our systems and use it.
11+
//! Finally, after all that we can access the `LogEvent` event from our systems and use it.
1212
//! In this example we build a simple log viewer.
1313
1414
use std::sync::mpsc;
@@ -32,7 +32,7 @@ struct LogEvent {
3232
#[derive(Deref, DerefMut)]
3333
struct CapturedLogEvents(mpsc::Receiver<LogEvent>);
3434

35-
/// Transfers information from the [`LogEvents`] resource to [`Events<LogEvent>`](LogEvent).
35+
/// Transfers information from the `LogEvents` resource to [`Events<LogEvent>`](LogEvent).
3636
fn transfer_log_events(
3737
receiver: NonSend<CapturedLogEvents>,
3838
mut log_events: EventWriter<LogEvent>,

examples/asset/asset_decompression.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct GzAssetLoader;
2424
/// Possible errors that can be produced by [`GzAssetLoader`]
2525
#[non_exhaustive]
2626
#[derive(Debug, Error)]
27-
pub enum GzAssetLoaderError {
27+
enum GzAssetLoaderError {
2828
/// An [IO](std::io) Error
2929
#[error("Could not load asset: {0}")]
3030
Io(#[from] std::io::Error),

examples/asset/custom_asset.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct CustomAssetLoader;
2020
/// Possible errors that can be produced by [`CustomAssetLoader`]
2121
#[non_exhaustive]
2222
#[derive(Debug, Error)]
23-
pub enum CustomAssetLoaderError {
23+
enum CustomAssetLoaderError {
2424
/// An [IO](std::io) Error
2525
#[error("Could not load asset: {0}")]
2626
Io(#[from] std::io::Error),
@@ -58,10 +58,10 @@ struct Blob {
5858
#[derive(Default)]
5959
struct BlobAssetLoader;
6060

61-
/// Possible errors that can be produced by [`CustomAssetLoader`]
61+
/// Possible errors that can be produced by [`BlobAssetLoader`]
6262
#[non_exhaustive]
6363
#[derive(Debug, Error)]
64-
pub enum BlobAssetLoaderError {
64+
enum BlobAssetLoaderError {
6565
/// An [IO](std::io) Error
6666
#[error("Could not load file: {0}")]
6767
Io(#[from] std::io::Error),

examples/asset/processing/asset_processing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn main() {
5151
/// It also defines an asset processor that will load [`CoolText`], resolve embedded dependencies, and write the resulting
5252
/// output to a "normal" plain text file. When the processed asset is loaded, it is loaded as a Text (plaintext) asset.
5353
/// This illustrates that when you process an asset, you can change its type! However you don't _need_ to change the type.
54-
pub struct TextPlugin;
54+
struct TextPlugin;
5555

5656
impl Plugin for TextPlugin {
5757
fn build(&self, app: &mut App) {

examples/ecs/custom_query_param.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! This example illustrates the usage of the [`WorldQuery`] derive macro, which allows
1+
//! This example illustrates the usage of the [`QueryData`] derive macro, which allows
22
//! defining custom query and filter types.
33
//!
44
//! While regular tuple queries work great in most of simple scenarios, using custom queries
@@ -10,7 +10,7 @@
1010
//! - Named structs enable the composition pattern, that makes query types easier to re-use.
1111
//! - You can bypass the limit of 15 components that exists for query tuples.
1212
//!
13-
//! For more details on the `WorldQuery` derive macro, see the trait documentation.
13+
//! For more details on the [`QueryData`] derive macro, see the trait documentation.
1414
1515
use bevy::{
1616
ecs::query::{QueryData, QueryFilter},
@@ -77,11 +77,11 @@ fn print_components_read_only(
7777
println!();
7878
}
7979

80-
// If you are going to mutate the data in a query, you must mark it with the `mutable` attribute.
81-
// The `WorldQuery` derive macro will still create a read-only version, which will be have `ReadOnly`
82-
// suffix.
83-
// Note: if you want to use derive macros with read-only query variants, you need to pass them with
84-
// using the `derive` attribute.
80+
/// If you are going to mutate the data in a query, you must mark it with the `mutable` attribute.
81+
/// The [`QueryData`] derive macro will still create a read-only version, which will be have `ReadOnly`
82+
/// suffix.
83+
/// Note: if you want to use derive macros with read-only query variants, you need to pass them with
84+
/// using the `derive` attribute.
8585
#[derive(QueryData)]
8686
#[query_data(mutable, derive(Debug))]
8787
struct CustomQuery<T: Component + Debug, P: Component + Debug> {

0 commit comments

Comments
 (0)