Skip to content

Commit

Permalink
More Doctest changes (#1405)
Browse files Browse the repository at this point in the history
* Add system() to DocTests

* Hide use statements
  • Loading branch information
MinerSebas authored Feb 6, 2021
1 parent c87d4c1 commit 3475a64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use bevy_utils::tracing::info_span;
/// ## Example
/// Here is a simple "Hello World" Bevy app:
/// ```
///use bevy_app::prelude::*;
///use bevy_ecs::prelude::*;
///# use bevy_app::prelude::*;
///# use bevy_ecs::prelude::*;
///
///fn main() {
/// App::build()
Expand Down
12 changes: 8 additions & 4 deletions crates/bevy_ecs/src/system/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl Commands {
/// # Example
///
/// ```
/// use bevy_ecs::prelude::*;
/// # use bevy_ecs::prelude::*;
///
/// struct Component1;
/// struct Component2;
Expand All @@ -206,7 +206,7 @@ impl Commands {
/// b: Component2,
/// }
///
/// fn example_system(mut commands: &mut Commands) {
/// fn example_system(commands: &mut Commands) {
/// // Create a new entity with a component bundle.
/// commands.spawn(ExampleBundle {
/// a: Component1,
Expand All @@ -218,6 +218,8 @@ impl Commands {
/// // Create a new entity with two components.
/// commands.spawn((Component1, Component2));
/// }
///
/// # example_system.system();
/// ```
pub fn spawn(&mut self, bundle: impl DynamicBundle + Send + Sync + 'static) -> &mut Self {
let entity = self
Expand Down Expand Up @@ -327,12 +329,12 @@ impl Commands {
/// `with` can be chained with [`Self::spawn`].
///
/// ```
/// use bevy_ecs::prelude::*;
/// # use bevy_ecs::prelude::*;
///
/// struct Component1;
/// struct Component2;
///
/// fn example_system(mut commands: Commands) {
/// fn example_system(commands: &mut Commands) {
/// // Create a new entity with a `Component1` and `Component2`.
/// commands.spawn((Component1,)).with(Component2);
///
Expand All @@ -349,6 +351,8 @@ impl Commands {
/// b: Component2,
/// });
/// }
///
/// # example_system.system();
/// ```
pub fn with(&mut self, component: impl Component) -> &mut Self {
let current_entity = self.current_entity.expect("Cannot add component because the 'current entity' is not set. You should spawn an entity first.");
Expand Down

0 comments on commit 3475a64

Please sign in to comment.