From bbc784c411089e723f66ab5685bbe4aa38075c5a Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:09:25 -0600 Subject: [PATCH 01/19] fix duplication of cfg_attr --- src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6c90ff1a0b903..9ceedc72f458c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,7 @@ +#![doc( + html_logo_url = "https://bevyengine.org/assets/icon.png", + html_favicon_url = "https://bevyengine.org/assets/icon.png" +)] #![allow(clippy::single_component_path_imports)] #![cfg_attr(docsrs, feature(doc_auto_cfg))] @@ -40,11 +44,8 @@ //! If you prefer, you can also consume the individual bevy crates directly. //! Each module in the root of this crate, except for the prelude, can be found on crates.io //! with `bevy_` appended to the front, e.g. `app` -> [`bevy_app`](https://docs.rs/bevy_app/*/bevy_app/). + #![doc = include_str!("../docs/cargo_features.md")] -#![doc( - html_logo_url = "https://bevyengine.org/assets/icon.png", - html_favicon_url = "https://bevyengine.org/assets/icon.png" -)] pub use bevy_internal::*; From c31fea7fd03f5c46e9f3ad6a80a2a2ca50f71d22 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:49:02 -0600 Subject: [PATCH 02/19] Rectangle instead of Quad in Docs --- examples/2d/mesh2d.rs | 4 +--- examples/2d/mesh2d_vertex_color_texture.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/examples/2d/mesh2d.rs b/examples/2d/mesh2d.rs index e21350fcf0b39..51c2c6c5da2dd 100644 --- a/examples/2d/mesh2d.rs +++ b/examples/2d/mesh2d.rs @@ -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}; diff --git a/examples/2d/mesh2d_vertex_color_texture.rs b/examples/2d/mesh2d_vertex_color_texture.rs index f0a41c60c951a..654c8e118d957 100644 --- a/examples/2d/mesh2d_vertex_color_texture.rs +++ b/examples/2d/mesh2d_vertex_color_texture.rs @@ -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::*, From c501e67dd3898921329ef186dd3ad4a8c2e1eada Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:49:37 -0600 Subject: [PATCH 03/19] remove pub in examples --- examples/asset/asset_decompression.rs | 2 +- examples/asset/custom_asset.rs | 6 +++--- examples/asset/processing/asset_processing.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/asset/asset_decompression.rs b/examples/asset/asset_decompression.rs index f003471a72bb7..13bbb0d05895c 100644 --- a/examples/asset/asset_decompression.rs +++ b/examples/asset/asset_decompression.rs @@ -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), diff --git a/examples/asset/custom_asset.rs b/examples/asset/custom_asset.rs index b3167bbd1d8bb..31e75414a8762 100644 --- a/examples/asset/custom_asset.rs +++ b/examples/asset/custom_asset.rs @@ -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), @@ -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), diff --git a/examples/asset/processing/asset_processing.rs b/examples/asset/processing/asset_processing.rs index f99fc4769a4ca..41f9af1e1b512 100644 --- a/examples/asset/processing/asset_processing.rs +++ b/examples/asset/processing/asset_processing.rs @@ -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) { From c47cf7a9a738758de08227af0fecb103087155da Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:50:01 -0600 Subject: [PATCH 04/19] use QueryData instead of WorldQuery in docs --- examples/ecs/custom_query_param.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/ecs/custom_query_param.rs b/examples/ecs/custom_query_param.rs index 4df666bf337e5..43b02df732527 100644 --- a/examples/ecs/custom_query_param.rs +++ b/examples/ecs/custom_query_param.rs @@ -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 @@ -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}, @@ -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 { From 1e23f17b33a27a053b95b1c707f59cc15cc9e9af Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:01:39 -0600 Subject: [PATCH 05/19] =?UTF-8?q?add=20doc-scrape=E2=80=93examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 019ce0c6e9059..ff79fe9808d43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1158,6 +1158,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" @@ -1168,6 +1169,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" From 4f5f7b95b2dcb3f9c1544d0ff7e095dd835c60c2 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:01:52 -0600 Subject: [PATCH 06/19] fix log_layers_ecs docs --- examples/app/log_layers_ecs.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index 9c4ad4ee6e134..c30e4aa129d71 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -4,9 +4,9 @@ //! 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`]. +//! [`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. //! In this example we build a simple log viewer. @@ -23,17 +23,17 @@ use bevy::{ /// A basic message. This is what we will be sending from the [`CaptureLayer`] to [`CapturedLogEvents`] non-send resource. #[derive(Debug, Event)] -struct LogEvent { +pub struct LogEvent { message: String, } /// This non-send resource temporarily stores [`LogEvent`]s before they are /// written to [`Events`] by [`transfer_log_events`]. #[derive(Deref, DerefMut)] -struct CapturedLogEvents(mpsc::Receiver); +pub struct CapturedLogEvents(mpsc::Receiver); -/// Transfers information from the [`LogEvents`] resource to [`Events`](LogEvent). -fn transfer_log_events( +/// Transfers information from the `LCogEvents` resource to [`Events`](LogEvent). +pub fn transfer_log_events( receiver: NonSend, mut log_events: EventWriter, ) { @@ -43,7 +43,7 @@ fn transfer_log_events( /// This is the [`Layer`] that we will use to capture log events and then send them to Bevy's /// ECS via it's [`mpsc::Sender`]. -struct CaptureLayer { +pub struct CaptureLayer { sender: mpsc::Sender, } impl Layer for CaptureLayer { @@ -77,7 +77,8 @@ impl tracing::field::Visit for CaptureLayerVisitor<'_> { } } } -fn update_subscriber(app: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber { +/// Update Subscriber +pub fn update_subscriber(app: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber { let (sender, receiver) = mpsc::channel(); let layer = CaptureLayer { sender }; From 378c431b8f904d9d7e85d2ce83c66058cfae1ce0 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:02:48 -0600 Subject: [PATCH 07/19] allow redundant_explicit_links --- crates/bevy_winit/src/winit_config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_winit/src/winit_config.rs b/crates/bevy_winit/src/winit_config.rs index 3400e86ba27da..d0fe4739cfd12 100644 --- a/crates/bevy_winit/src/winit_config.rs +++ b/crates/bevy_winit/src/winit_config.rs @@ -58,6 +58,7 @@ impl Default for WinitSettings { } } +#[allow(rustdoc::redundant_explicit_links)] /// Determines how frequently an [`App`](bevy_app::App) should update. /// /// **Note:** This setting is independent of VSync. VSync is controlled by a window's From 10ce4d072ca0977a0e23a8cfec4f87b25af1bca5 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:05:53 -0600 Subject: [PATCH 08/19] Same docs settings, for ci and deployment --- .github/workflows/docs.yml | 5 +---- tools/ci/src/main.rs | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5f163f757d5e9..5264f32bdca67 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -49,10 +49,7 @@ jobs: echo "" > header.html - name: Build docs - env: - # needs to be in sync with [package.metadata.docs.rs] - RUSTDOCFLAGS: -Zunstable-options --cfg=docsrs - run: cargo doc --all-features --no-deps -p bevy -Zunstable-options -Zrustdoc-scrape-examples + run: cargo run -p ci -- doc-check --deploy-docs # This adds the following: # - A top level redirect to the bevy crate documentation diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 617f96f7f7da8..6bc62d516cea8 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -25,6 +25,7 @@ bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq)] struct Flag: u32 { const KEEP_GOING = 0b00000001; + const DEPLOY_DOCS = 0b00000010; } } @@ -68,7 +69,10 @@ fn main() { ("doc-test", Check::DOC_TEST), ]; - let flag_arguments = [("--keep-going", Flag::KEEP_GOING)]; + let flag_arguments = [ + ("--keep-going", Flag::KEEP_GOING), + ("--deploy-docs", Flag::DEPLOY_DOCS), + ]; // Parameters are parsed disregarding their order. Note that the first arg is generally the name of // the executable, so it is ignored. Any parameter may either be a flag or the name of a battery of tests @@ -220,24 +224,33 @@ fn main() { } if checks.contains(Check::DOC_CHECK) { - // Check that building docs work and does not emit warnings + // Check that building docs work let mut args = vec![ "--workspace", "--all-features", "--no-deps", - "--document-private-items", + "-Zunstable-options", + "-Zrustdoc-scrape-examples", ]; if flags.contains(Flag::KEEP_GOING) { args.push("--keep-going"); } + if flags.contains(Flag::DEPLOY_DOCS) { + args.remove(args.iter().position(|&arg| arg == "--workspace").unwrap()); + args.push("-p"); + args.push("bevy"); + } test_suite.insert( Check::DOC_CHECK, vec![CITest { - command: cmd!(sh, "cargo doc {args...}"), + command: cmd!(sh, "cargo +nightly doc {args...}"), failure_message: "Please fix doc warnings in output above.", subdir: None, - env_vars: vec![("RUSTDOCFLAGS", "-D warnings")], + env_vars: vec![( + "RUSTDOCFLAGS", + "-D warnings -Zunstable-options --cfg=docsrs", + )], }], ); } From 2647b52b3cd9abd92efeed788ac1c31b8cf8231e Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:16:15 -0600 Subject: [PATCH 09/19] return comment, deleted by mistake --- tools/ci/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 6bc62d516cea8..a61174d464e79 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -224,7 +224,7 @@ fn main() { } if checks.contains(Check::DOC_CHECK) { - // Check that building docs work + // Check that building docs work and does not emit warnings let mut args = vec![ "--workspace", "--all-features", From 153502c762573344806550a3bc6a02a9dc2a6128 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:24:10 -0600 Subject: [PATCH 10/19] use nightly toolchain --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc4f2beeea01e..5658dd4488184 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -283,7 +283,7 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-check-doc-${{ hashFiles('**/Cargo.toml') }} - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@nightly - name: Install alsa and udev run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Build and check doc From 10d57f14ba3977fb945ebf631548844befc4f5da Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:34:00 -0600 Subject: [PATCH 11/19] separate ci, check doc and doc test individually --- .github/workflows/ci.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5658dd4488184..5775488a168e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -288,7 +288,7 @@ jobs: run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Build and check doc # See tools/ci/src/main.rs for the commands this runs - run: cargo run -p ci -- doc + run: cargo run -p ci -- doc-check env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-C debuginfo=0" @@ -300,6 +300,30 @@ jobs: # run: cargo deadlinks --dir target/doc/bevy # continue-on-error: true + check-doc-test: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-check-doc-test-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@nightly + - name: Install alsa and udev + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev + - name: Build and check doc + # See tools/ci/src/main.rs for the commands this runs + run: cargo run -p ci -- doc-test + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-C debuginfo=0" + check-missing-examples-in-docs: runs-on: ubuntu-latest timeout-minutes: 30 From 680d0155432fa4f784d96023e6b8336fca5a695c Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:35:27 -0600 Subject: [PATCH 12/19] use stable toolchain in doc test ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5775488a168e8..fec3e96c16dce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -314,7 +314,7 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-check-doc-test-${{ hashFiles('**/Cargo.toml') }} - - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/rust-toolchain@stable - name: Install alsa and udev run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Build and check doc From a4f4279123efbefb507eb31e9806e9f55e4df254 Mon Sep 17 00:00:00 2001 From: Ame <104745335+ameknite@users.noreply.github.com> Date: Sun, 31 Mar 2024 13:28:43 -0600 Subject: [PATCH 13/19] Update crates/bevy_winit/src/winit_config.rs Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com> --- crates/bevy_winit/src/winit_config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_winit/src/winit_config.rs b/crates/bevy_winit/src/winit_config.rs index d0fe4739cfd12..674479fb6716e 100644 --- a/crates/bevy_winit/src/winit_config.rs +++ b/crates/bevy_winit/src/winit_config.rs @@ -58,6 +58,7 @@ impl Default for WinitSettings { } } +// rustdoc mistakenly thinks `App` does not need an explicit link. #[allow(rustdoc::redundant_explicit_links)] /// Determines how frequently an [`App`](bevy_app::App) should update. /// From 6c4e0cb785690a83d0cf5aad9bf9c72bcba450c9 Mon Sep 17 00:00:00 2001 From: Ame <104745335+ameknite@users.noreply.github.com> Date: Sun, 31 Mar 2024 13:30:14 -0600 Subject: [PATCH 14/19] LCogEvents -> LogEvents Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com> --- examples/app/log_layers_ecs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index c30e4aa129d71..343960a442a4b 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -32,7 +32,7 @@ pub struct LogEvent { #[derive(Deref, DerefMut)] pub struct CapturedLogEvents(mpsc::Receiver); -/// Transfers information from the `LCogEvents` resource to [`Events`](LogEvent). +/// Transfers information from the `LogEvents` resource to [`Events`](LogEvent). pub fn transfer_log_events( receiver: NonSend, mut log_events: EventWriter, From d145809bd9f79e1b5abb94bded775f67549eee42 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 31 Mar 2024 13:44:45 -0600 Subject: [PATCH 15/19] make items private --- examples/app/log_layers_ecs.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index 343960a442a4b..fe2ab0ee91faa 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -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 +//! 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`]. +//! 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; @@ -23,17 +23,17 @@ use bevy::{ /// A basic message. This is what we will be sending from the [`CaptureLayer`] to [`CapturedLogEvents`] non-send resource. #[derive(Debug, Event)] -pub struct LogEvent { +struct LogEvent { message: String, } /// This non-send resource temporarily stores [`LogEvent`]s before they are /// written to [`Events`] by [`transfer_log_events`]. #[derive(Deref, DerefMut)] -pub struct CapturedLogEvents(mpsc::Receiver); +struct CapturedLogEvents(mpsc::Receiver); /// Transfers information from the `LogEvents` resource to [`Events`](LogEvent). -pub fn transfer_log_events( +fn transfer_log_events( receiver: NonSend, mut log_events: EventWriter, ) { @@ -43,7 +43,7 @@ pub fn transfer_log_events( /// This is the [`Layer`] that we will use to capture log events and then send them to Bevy's /// ECS via it's [`mpsc::Sender`]. -pub struct CaptureLayer { +struct CaptureLayer { sender: mpsc::Sender, } impl Layer for CaptureLayer { @@ -77,8 +77,8 @@ impl tracing::field::Visit for CaptureLayerVisitor<'_> { } } } -/// Update Subscriber -pub fn update_subscriber(app: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber { + +fn update_subscriber(app: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber { let (sender, receiver) = mpsc::channel(); let layer = CaptureLayer { sender }; From 0ad29eab5e70b6b22f27a25034d9b13f1057beb7 Mon Sep 17 00:00:00 2001 From: Ame <104745335+ameknite@users.noreply.github.com> Date: Sun, 31 Mar 2024 13:57:31 -0600 Subject: [PATCH 16/19] use explicit toolchain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Mockers --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fec3e96c16dce..ed1e9721dc970 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -283,7 +283,9 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-check-doc-${{ hashFiles('**/Cargo.toml') }} - - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} - name: Install alsa and udev run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Build and check doc From 476ec5fc95ffe8e9c20b21d97184b47b1649f6d3 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 31 Mar 2024 14:43:39 -0600 Subject: [PATCH 17/19] change to only use nightly with --deploy-docs --- .github/workflows/ci.yml | 2 +- tools/ci/src/main.rs | 32 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed1e9721dc970..bbcf4913bef3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -290,7 +290,7 @@ jobs: run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Build and check doc # See tools/ci/src/main.rs for the commands this runs - run: cargo run -p ci -- doc-check + run: cargo run -p ci -- doc-check --deploy-docs env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-C debuginfo=0" diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index a61174d464e79..decce381f685a 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -225,32 +225,30 @@ fn main() { if checks.contains(Check::DOC_CHECK) { // Check that building docs work and does not emit warnings - let mut args = vec![ - "--workspace", - "--all-features", - "--no-deps", - "-Zunstable-options", - "-Zrustdoc-scrape-examples", - ]; - if flags.contains(Flag::KEEP_GOING) { - args.push("--keep-going"); - } + let mut args = vec!["--workspace", "--all-features", "--no-deps"]; + let mut rust_doc_flags = "-D warnings"; + let mut docs_type = vec!["doc"]; + if flags.contains(Flag::DEPLOY_DOCS) { + // Nightly + docs_type.insert(0, "+nightly"); + rust_doc_flags = "-D warnings -Zunstable-options --cfg=docsrs"; args.remove(args.iter().position(|&arg| arg == "--workspace").unwrap()); - args.push("-p"); - args.push("bevy"); + args.push("-Zunstable-options"); + args.push("-Zrustdoc-scrape-examples"); + } + + if flags.contains(Flag::KEEP_GOING) { + args.push("--keep-going"); } test_suite.insert( Check::DOC_CHECK, vec![CITest { - command: cmd!(sh, "cargo +nightly doc {args...}"), + command: cmd!(sh, "cargo {docs_type...} {args...}"), failure_message: "Please fix doc warnings in output above.", subdir: None, - env_vars: vec![( - "RUSTDOCFLAGS", - "-D warnings -Zunstable-options --cfg=docsrs", - )], + env_vars: vec![("RUSTDOCFLAGS", rust_doc_flags)], }], ); } From 40a6ec96517835399411619e07a1724b7168e0d0 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 31 Mar 2024 14:45:34 -0600 Subject: [PATCH 18/19] always use --workspace --- tools/ci/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index decce381f685a..c297c121ca43e 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -233,7 +233,6 @@ fn main() { // Nightly docs_type.insert(0, "+nightly"); rust_doc_flags = "-D warnings -Zunstable-options --cfg=docsrs"; - args.remove(args.iter().position(|&arg| arg == "--workspace").unwrap()); args.push("-Zunstable-options"); args.push("-Zrustdoc-scrape-examples"); } From 739d52e55e0e6067e2d2b7bd61a15cc50d411346 Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Sun, 31 Mar 2024 14:59:31 -0600 Subject: [PATCH 19/19] use nightly flag --- .github/workflows/ci.yml | 2 +- .github/workflows/docs.yml | 2 +- tools/ci/src/main.rs | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbcf4913bef3d..2d27e60ef8458 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -290,7 +290,7 @@ jobs: run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Build and check doc # See tools/ci/src/main.rs for the commands this runs - run: cargo run -p ci -- doc-check --deploy-docs + run: cargo run -p ci -- doc-check --nightly env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-C debuginfo=0" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5264f32bdca67..2400f8376d61e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -49,7 +49,7 @@ jobs: echo "" > header.html - name: Build docs - run: cargo run -p ci -- doc-check --deploy-docs + run: cargo run -p ci -- doc-check --nightly --deploy-docs # This adds the following: # - A top level redirect to the bevy crate documentation diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index c297c121ca43e..dcfdafe95357c 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -24,8 +24,9 @@ bitflags! { bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq)] struct Flag: u32 { - const KEEP_GOING = 0b00000001; - const DEPLOY_DOCS = 0b00000010; + const NIGHTLY = 0b00000001; + const KEEP_GOING = 0b00000010; + const DEPLOY_DOCS = 0b00000100; } } @@ -70,6 +71,7 @@ fn main() { ]; let flag_arguments = [ + ("--nightly", Flag::KEEP_GOING), ("--keep-going", Flag::KEEP_GOING), ("--deploy-docs", Flag::DEPLOY_DOCS), ]; @@ -229,14 +231,19 @@ fn main() { let mut rust_doc_flags = "-D warnings"; let mut docs_type = vec!["doc"]; - if flags.contains(Flag::DEPLOY_DOCS) { - // Nightly + if flags.contains(Flag::NIGHTLY) { docs_type.insert(0, "+nightly"); rust_doc_flags = "-D warnings -Zunstable-options --cfg=docsrs"; args.push("-Zunstable-options"); args.push("-Zrustdoc-scrape-examples"); } + if flags.contains(Flag::DEPLOY_DOCS) { + args.remove(args.iter().position(|&arg| arg == "--workspace").unwrap()); + args.push("-p"); + args.push("bevy"); + } + if flags.contains(Flag::KEEP_GOING) { args.push("--keep-going"); } @@ -306,7 +313,7 @@ fn main() { ); } - if checks.contains(Check::CFG_CHECK) { + if checks.contains(Check::CFG_CHECK) && flags.contains(Flag::NIGHTLY) { // Check cfg and imports let mut args = vec!["-Zcheck-cfg", "--workspace"]; if flags.contains(Flag::KEEP_GOING) {