From 6430b561c8b442a5725221f798d64dd8ad29c41c Mon Sep 17 00:00:00 2001 From: Jordan Ellis Coppard Date: Sun, 30 Jul 2023 23:46:16 +0800 Subject: [PATCH] improve documentation relating to `WindowPlugin` and `Window` (#9173) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - attempt to clarify with better docstrings the default behaviour of WindowPlugin and the component type it accepts. # Objective - I'm new to Rust and Bevy, I got a bit confused about how to customise some window parameters (title, height, width etc) and while the docs do show the struct code for that field `Option` I was a bit of a doofus and skipped that to read the docstring entry for `primary_window` and then the `Window` component directly which aren't linked together. This is a minor improvement which I think will help in-case others, like me, have a doofus moment. --------- Co-authored-by: Sélène Amanita <134181069+Selene-Amanita@users.noreply.github.com> --- crates/bevy_window/src/lib.rs | 13 ++++++++----- crates/bevy_window/src/window.rs | 13 +++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/crates/bevy_window/src/lib.rs b/crates/bevy_window/src/lib.rs index 3ae1c083c8..79d15d724e 100644 --- a/crates/bevy_window/src/lib.rs +++ b/crates/bevy_window/src/lib.rs @@ -38,12 +38,15 @@ impl Default for WindowPlugin { /// A [`Plugin`] that defines an interface for windowing support in Bevy. pub struct WindowPlugin { - /// Settings for the primary window. This will be spawned by - /// default, with the marker component [`PrimaryWindow`](PrimaryWindow). - /// If you want to run without a primary window you should set this to `None`. + /// Settings for the primary window. /// - /// Note that if there are no windows, by default the App will exit, - /// due to [`exit_on_all_closed`]. + /// `Some(custom_window)` will spawn an entity with `custom_window` and [`PrimaryWindow`] as components. + /// `None` will not spawn a primary window. + /// + /// Defaults to `Some(Window::default())`. + /// + /// Note that if there are no windows the App will exit (by default) due to + /// [`exit_on_all_closed`]. pub primary_window: Option, /// Whether to exit the app when there are no open windows. diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index f73fe31583..f6346500eb 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -16,8 +16,9 @@ use crate::CursorIcon; /// /// Currently this is assumed to only exist on 1 entity at a time. /// -/// [`WindowPlugin`](crate::WindowPlugin) will spawn a window entity -/// with this component if `primary_window` is `Some`. +/// [`WindowPlugin`](crate::WindowPlugin) will spawn a [`Window`] entity +/// with this component if [`primary_window`](crate::WindowPlugin::primary_window) +/// is `Some`. #[derive(Default, Debug, Component, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Reflect)] #[reflect(Component)] pub struct PrimaryWindow; @@ -234,16 +235,16 @@ impl Default for Window { } impl Window { - /// Setting this to true will attempt to maximize the window. + /// Setting to true will attempt to maximize the window. /// - /// Setting it to false will attempt to un-maximize the window. + /// Setting to false will attempt to un-maximize the window. pub fn set_maximized(&mut self, maximized: bool) { self.internal.maximize_request = Some(maximized); } - /// Setting this to true will attempt to minimize the window. + /// Setting to true will attempt to minimize the window. /// - /// Setting it to false will attempt to un-minimize the window. + /// Setting to false will attempt to un-minimize the window. pub fn set_minimized(&mut self, minimized: bool) { self.internal.minimize_request = Some(minimized); }