From 2c1e4c85b4e9f8e4866020cd8eed135610f659ac Mon Sep 17 00:00:00 2001 From: Daniel Nelsen Date: Sat, 31 Jul 2021 10:03:57 -0700 Subject: [PATCH 1/8] Add readme as docs to relevant crates. --- crates/bevy_ecs/src/lib.rs | 2 ++ crates/bevy_reflect/src/lib.rs | 2 ++ crates/bevy_tasks/src/lib.rs | 2 ++ crates/bevy_transform/src/lib.rs | 2 ++ 4 files changed, 8 insertions(+) diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 988d020aaab4a..941541cd6eb61 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -1,3 +1,5 @@ +#![doc = include_str!("../README.md")] + pub mod archetype; pub mod bundle; pub mod change_detection; diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 7726ce7ee4e76..29929df9f85d8 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -1,3 +1,5 @@ +#![doc = include_str!("../README.md")] + mod list; mod map; mod path; diff --git a/crates/bevy_tasks/src/lib.rs b/crates/bevy_tasks/src/lib.rs index 08d7dfc42b988..db95dc28db447 100644 --- a/crates/bevy_tasks/src/lib.rs +++ b/crates/bevy_tasks/src/lib.rs @@ -1,3 +1,5 @@ +#![doc = include_str!("../README.md")] + mod slice; pub use slice::{ParallelSlice, ParallelSliceMut}; diff --git a/crates/bevy_transform/src/lib.rs b/crates/bevy_transform/src/lib.rs index f255c613db814..fa917bf40d889 100644 --- a/crates/bevy_transform/src/lib.rs +++ b/crates/bevy_transform/src/lib.rs @@ -1,3 +1,5 @@ +#![doc = include_str!("../README.md")] + pub mod components; pub mod hierarchy; pub mod transform_propagate_system; From 9f096ecb830b15943bef87d520e1c696de6868e7 Mon Sep 17 00:00:00 2001 From: Daniel Nelsen Date: Sun, 1 Aug 2021 08:43:53 -0700 Subject: [PATCH 2/8] Try ignoring a few docs for github --- crates/bevy_ecs/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ecs/README.md b/crates/bevy_ecs/README.md index 478b23b915a1f..8be5f967e0716 100644 --- a/crates/bevy_ecs/README.md +++ b/crates/bevy_ecs/README.md @@ -32,7 +32,7 @@ struct Position { x: f32, y: f32 } Entities, Components, and Resources are stored in a `World`. Worlds, much like Rust std collections like HashSet and Vec, expose operations to insert, read, write, and remove the data they store. -```rust +```rust ignore let world = World::default(); ``` @@ -40,7 +40,7 @@ let world = World::default(); Entities are unique identifiers that correlate to zero or more Components. -```rust +```rust ignore let entity = world.spawn() .insert(Position { x: 0.0, y: 0.0 }) .insert(Velocity { x: 1.0, y: 0.0 }) @@ -55,7 +55,7 @@ let velocity = entity_ref.get::().unwrap(); Systems are normal Rust functions. Thanks to the Rust type system, Bevy ECS can use function parameter types to determine what data needs to be sent to the system. It also uses this "data access" information to determine what Systems can run in parallel with each other. -```rust +```rust ignore fn print_position(query: Query<(Entity, &Position)>) { for (entity, position) in query.iter() { println!("Entity {:?} is at position: x {}, y {}", entity, position.x, position.y); @@ -67,7 +67,7 @@ fn print_position(query: Query<(Entity, &Position)>) { Apps often require unique resources, such as asset collections, renderers, audio servers, time, etc. Bevy ECS makes this pattern a first class citizen. `Resource` is a special kind of component that does not belong to any entity. Instead, it is identified uniquely by its type: -```rust +```rust ignore #[derive(Default)] struct Time { seconds: f32, From 664a47e1ffdcbf939c1f4bfdab93f7232facee8c Mon Sep 17 00:00:00 2001 From: Daniel Nelsen Date: Sun, 1 Aug 2021 08:50:44 -0700 Subject: [PATCH 3/8] Fix failing doc tests Ignore the doc tests in the readme, this allows "cargo test --doc -p *" to run without errors --- crates/bevy_ecs/README.md | 14 +++++++------- crates/bevy_reflect/README.md | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/bevy_ecs/README.md b/crates/bevy_ecs/README.md index 8be5f967e0716..40b1721d53899 100644 --- a/crates/bevy_ecs/README.md +++ b/crates/bevy_ecs/README.md @@ -95,7 +95,7 @@ The built in "parallel stage" considers dependencies between systems and (by def Bevy ECS should feel very natural for those familiar with Rust syntax: -```rust +```rust ignore use bevy_ecs::prelude::*; struct Velocity { @@ -143,7 +143,7 @@ fn main() { ### Query Filters -```rust +```rust ignore // Gets the Position component of all Entities with Player component and without the RedTeam component fn system(query: Query<&Position, (With, Without)>) { for position in query.iter() { @@ -157,7 +157,7 @@ Bevy ECS tracks _all_ changes to Components and Resources. Queries can filter for changed Components: -```rust +```rust ignore // Gets the Position component of all Entities whose Velocity has changed since the last run of the System fn system(query: Query<&Position, Changed>) { for position in query.iter() { @@ -173,7 +173,7 @@ fn system(query: Query<&Position, Added>) { Resources also expose change state: -```rust +```rust ignore // Prints "time changed!" if the Time resource has changed since the last run of the System fn system(time: Res