Skip to content

Commit

Permalink
Fix some doc warnings (bevyengine#12961)
Browse files Browse the repository at this point in the history
# Objective

- Fix some doc warnings 
- Add doc-scrape-examples to all examples

Moved from bevyengine#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/>
  • Loading branch information
ameknite authored Apr 14, 2024
1 parent 7a9a459 commit 0256dac
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 24 deletions.
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ wasm = true
[[example]]
name = "2d_viewport_to_world"
path = "examples/2d/2d_viewport_to_world.rs"
doc-scrape-examples = true

[package.metadata.example.2d_viewport_to_world]
name = "2D Viewport To World"
Expand Down Expand Up @@ -489,6 +490,7 @@ wasm = true
[[example]]
name = "sprite_tile"
path = "examples/2d/sprite_tile.rs"
doc-scrape-examples = true

[package.metadata.example.sprite_tile]
name = "Sprite Tile"
Expand All @@ -499,6 +501,7 @@ wasm = true
[[example]]
name = "sprite_slice"
path = "examples/2d/sprite_slice.rs"
doc-scrape-examples = true

[package.metadata.example.sprite_slice]
name = "Sprite Slice"
Expand Down Expand Up @@ -542,6 +545,7 @@ wasm = true
[[example]]
name = "pixel_grid_snap"
path = "examples/2d/pixel_grid_snap.rs"
doc-scrape-examples = true

[package.metadata.example.pixel_grid_snap]
name = "Pixel Grid Snapping"
Expand Down Expand Up @@ -729,6 +733,7 @@ wasm = true
[[example]]
name = "deferred_rendering"
path = "examples/3d/deferred_rendering.rs"
doc-scrape-examples = true

[package.metadata.example.deferred_rendering]
name = "Deferred Rendering"
Expand Down Expand Up @@ -893,6 +898,7 @@ wasm = true
[[example]]
name = "transmission"
path = "examples/3d/transmission.rs"
doc-scrape-examples = true

[package.metadata.example.transmission]
name = "Transmission"
Expand Down Expand Up @@ -1145,6 +1151,7 @@ wasm = true
[[example]]
name = "log_layers"
path = "examples/app/log_layers.rs"
doc-scrape-examples = true

[package.metadata.example.log_layers]
name = "Log layers"
Expand All @@ -1155,6 +1162,7 @@ wasm = false
[[example]]
name = "log_layers_ecs"
path = "examples/app/log_layers_ecs.rs"
doc-scrape-examples = true

[package.metadata.example.log_layers_ecs]
name = "Advanced log layers"
Expand Down Expand Up @@ -1423,6 +1431,7 @@ wasm = true
[[example]]
name = "pitch"
path = "examples/audio/pitch.rs"
doc-scrape-examples = true

[package.metadata.example.pitch]
name = "Pitch"
Expand Down Expand Up @@ -1595,6 +1604,7 @@ wasm = true
[[example]]
name = "one_shot_systems"
path = "examples/ecs/one_shot_systems.rs"
doc-scrape-examples = true

[package.metadata.example.one_shot_systems]
name = "One Shot Systems"
Expand Down Expand Up @@ -1706,6 +1716,7 @@ wasm = false
[[example]]
name = "time"
path = "examples/time/time.rs"
doc-scrape-examples = true

[package.metadata.example.time]
name = "Time handling"
Expand All @@ -1716,6 +1727,7 @@ wasm = false
[[example]]
name = "virtual_time"
path = "examples/time/virtual_time.rs"
doc-scrape-examples = true

[package.metadata.example.virtual_time]
name = "Virtual time"
Expand Down Expand Up @@ -2072,6 +2084,7 @@ wasm = true
[[example]]
name = "extended_material"
path = "examples/shader/extended_material.rs"
doc-scrape-examples = true

[package.metadata.example.extended_material]
name = "Extended Material"
Expand Down
4 changes: 1 addition & 3 deletions examples/2d/mesh2d.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Shows how to render a polygonal [`Mesh`], generated from a [`Quad`] primitive, in a 2D scene.
//!
//! [`Quad`]: shape::Quad
//! Shows how to render a polygonal [`Mesh`], generated from a [`Rectangle`] primitive, in a 2D scene.

use bevy::{color::palettes::basic::PURPLE, prelude::*, sprite::MaterialMesh2dBundle};

Expand Down
4 changes: 1 addition & 3 deletions examples/2d/mesh2d_vertex_color_texture.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Shows how to render a polygonal [`Mesh`], generated from a [`Quad`] primitive, in a 2D scene.
//! Shows how to render a polygonal [`Mesh`], generated from a [`Rectangle`] primitive, in a 2D scene.
//! Adds a texture and colored vertices, giving per-vertex tinting.
//!
//! [`Quad`]: shape::Quad

use bevy::{
prelude::*,
Expand Down
12 changes: 6 additions & 6 deletions examples/app/log_layers_ecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
//! The way we will do this is via a [`mpsc`] channel. [`mpsc`] channels allow 2 unrelated
//! parts of the program to communicate (in this case, [`Layer`]s and Bevy's ECS).
//!
//! Inside the [`update_subscriber`] function we will create a [`mpsc::Sender`] and a [`mpsc::Receiver`] from a
//! [`mpsc::channel`]. The [`Sender`](mpsc::Sender) will go into the [`AdvancedLayer`] and the [`Receiver`](mpsc::Receiver) will
//! go into a non-send resource called [`LogEvents`] (It has to be non-send because [`Receiver`](mpsc::Receiver) is [`!Sync`](Sync)).
//! From there we will use [`transfer_log_events`] to transfer log events from [`LogEvents`] to an ECS event called [`LogEvent`].
//! Inside the `update_subscriber` function we will create a [`mpsc::Sender`] and a [`mpsc::Receiver`] from a
//! [`mpsc::channel`]. The [`Sender`](mpsc::Sender) will go into the `AdvancedLayer` and the [`Receiver`](mpsc::Receiver) will
//! go into a non-send resource called `LogEvents` (It has to be non-send because [`Receiver`](mpsc::Receiver) is [`!Sync`](Sync)).
//! From there we will use `transfer_log_events` to transfer log events from `LogEvents` to an ECS event called `LogEvent`.
//!
//! Finally, after all that we can access the [`LogEvent`] event from our systems and use it.
//! Finally, after all that we can access the `LogEvent` event from our systems and use it.
//! In this example we build a simple log viewer.

use std::sync::mpsc;
Expand All @@ -32,7 +32,7 @@ struct LogEvent {
#[derive(Deref, DerefMut)]
struct CapturedLogEvents(mpsc::Receiver<LogEvent>);

/// Transfers information from the [`LogEvents`] resource to [`Events<LogEvent>`](LogEvent).
/// Transfers information from the `LogEvents` resource to [`Events<LogEvent>`](LogEvent).
fn transfer_log_events(
receiver: NonSend<CapturedLogEvents>,
mut log_events: EventWriter<LogEvent>,
Expand Down
2 changes: 1 addition & 1 deletion examples/asset/asset_decompression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct GzAssetLoader;
/// Possible errors that can be produced by [`GzAssetLoader`]
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum GzAssetLoaderError {
enum GzAssetLoaderError {
/// An [IO](std::io) Error
#[error("Could not load asset: {0}")]
Io(#[from] std::io::Error),
Expand Down
6 changes: 3 additions & 3 deletions examples/asset/custom_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CustomAssetLoader;
/// Possible errors that can be produced by [`CustomAssetLoader`]
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum CustomAssetLoaderError {
enum CustomAssetLoaderError {
/// An [IO](std::io) Error
#[error("Could not load asset: {0}")]
Io(#[from] std::io::Error),
Expand Down Expand Up @@ -58,10 +58,10 @@ struct Blob {
#[derive(Default)]
struct BlobAssetLoader;

/// Possible errors that can be produced by [`CustomAssetLoader`]
/// Possible errors that can be produced by [`BlobAssetLoader`]
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum BlobAssetLoaderError {
enum BlobAssetLoaderError {
/// An [IO](std::io) Error
#[error("Could not load file: {0}")]
Io(#[from] std::io::Error),
Expand Down
2 changes: 1 addition & 1 deletion examples/asset/processing/asset_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn main() {
/// It also defines an asset processor that will load [`CoolText`], resolve embedded dependencies, and write the resulting
/// output to a "normal" plain text file. When the processed asset is loaded, it is loaded as a Text (plaintext) asset.
/// This illustrates that when you process an asset, you can change its type! However you don't _need_ to change the type.
pub struct TextPlugin;
struct TextPlugin;

impl Plugin for TextPlugin {
fn build(&self, app: &mut App) {
Expand Down
14 changes: 7 additions & 7 deletions examples/ecs/custom_query_param.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This example illustrates the usage of the [`WorldQuery`] derive macro, which allows
//! This example illustrates the usage of the [`QueryData`] derive macro, which allows
//! defining custom query and filter types.
//!
//! While regular tuple queries work great in most of simple scenarios, using custom queries
Expand All @@ -10,7 +10,7 @@
//! - Named structs enable the composition pattern, that makes query types easier to re-use.
//! - You can bypass the limit of 15 components that exists for query tuples.
//!
//! For more details on the `WorldQuery` derive macro, see the trait documentation.
//! For more details on the [`QueryData`] derive macro, see the trait documentation.

use bevy::{
ecs::query::{QueryData, QueryFilter},
Expand Down Expand Up @@ -77,11 +77,11 @@ fn print_components_read_only(
println!();
}

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

0 comments on commit 0256dac

Please sign in to comment.