Skip to content

Commit e6d7d25

Browse files
committed
fixup docs
1 parent 791f63c commit e6d7d25

File tree

8 files changed

+73
-57
lines changed

8 files changed

+73
-57
lines changed

crates/stecs-derive/src/split.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl Struct {
213213

214214
let struct_ref_doc = format!(
215215
r#"Generated by `#[derive(SplitFields)]`.
216-
This struct is a version of `{struct_name}` that holds references to its fields."#
216+
This struct is a version of [`{struct_name}`] that holds references to its fields."#
217217
);
218218

219219
let struct_ref = quote! {
@@ -267,7 +267,7 @@ This struct is a version of `{struct_name}` that holds references to its fields.
267267

268268
let struct_ref_mut_doc = format!(
269269
r#"Generated by `#[derive(SplitFields)]`.
270-
This struct is a version of `{struct_name}` that holds mutable references to its fields."#
270+
This struct is a version of [`{struct_name}`] that holds mutable references to its fields."#
271271
);
272272

273273
let struct_ref = quote! {
@@ -349,9 +349,9 @@ This struct is a version of `{struct_name}` that holds mutable references to its
349349

350350
let struct_of_doc = format!(
351351
r#"Generated by `#[derive(SplitFields)]`.
352-
This struct is a version of `{struct_name}` that holds each field in its own [Storage](::stecs::storage::Storage).
352+
This struct is a version of [`{struct_name}`] that holds each field in its own [Storage](::stecs::storage::Storage).
353353
354-
**Note**: It is used by other generated structures and does not need to be used by user code."#
354+
**Note**: It is not intended to be used directly, as it is used by other generated structures."#
355355
);
356356

357357
quote! {
@@ -367,20 +367,36 @@ This struct is a version of `{struct_name}` that holds each field in its own [St
367367
#[cfg(not(feature = "dynamic"))]
368368
let dynamic = quote! {};
369369
#[cfg(feature = "dynamic")]
370-
let dynamic =
371-
quote! { pub r#dyn: ::stecs::dynamic::DynamicStorage<#generic_family_name>, };
370+
let dynamic = quote! {
371+
/// Dynamic components attached to the archetype.
372+
///
373+
/// **Note**: not intended to be used directly,
374+
/// but rather via methods and querying macros.
375+
/// *It is only exposed to be accessible in queries*.
376+
pub r#dyn: ::stecs::dynamic::DynamicStorage<#generic_family_name>,
377+
};
372378

373379
let struct_of_doc = format!(
374380
r#"Generated by `#[derive(SplitFields)]`.
375-
This struct is a version of `{struct_name}` that holds each field in its own [Storage](::stecs::storage::Storage).
381+
This struct is a version of [`{struct_name}`] that holds each field in its own [Storage](::stecs::storage::Storage).
376382
377-
**Note**: It is not intended to be used directly, but rather as, for example, `StructOf<Vec<{struct_name}>>`."#
383+
**Note**: It is not intended to be used directly, but rather as, for example, `StructOf<Dense<{struct_name}>>`."#
378384
);
379385

380386
quote! {
381387
#[doc = #struct_of_doc]
382388
#vis struct #struct_of_name<#generics_family> {
389+
/// The id's of all existing entities belonging to this archetype.
390+
///
391+
/// **Note**: not intended to be used directly,
392+
/// but rather via methods and querying macros.
393+
/// *It is only exposed to be accessible in queries*.
383394
pub ids: #generic_family_name::Generator,
395+
/// The inner fields of the archetype.
396+
///
397+
/// **Note**: not intended to be used directly,
398+
/// but rather via methods and querying macros.
399+
/// *It is only exposed to be accessible in queries*.
384400
pub inner: #struct_split_name<#generics_family_use>,
385401
#dynamic
386402
}

examples/blogpost.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ use stecs::prelude::*;
55
// Define an Archetype
66
#[derive(SplitFields)]
77
#[split(debug, clone)] // derive Debug and Clone for generated reference types
8-
struct Monster {
9-
position: (f32, f32),
10-
health: f32,
11-
tick: usize,
12-
damage: Option<f32>,
8+
pub struct Monster {
9+
pub position: (f32, f32),
10+
pub health: f32,
11+
pub tick: usize,
12+
pub damage: Option<f32>,
1313
}
1414

1515
#[derive(SplitFields)]
16-
struct Corpse {
16+
pub struct Corpse {
1717
#[split(nested)]
18-
monster: Monster,
19-
time: f32,
18+
pub monster: Monster,
19+
pub time: f32,
2020
}
2121

22-
struct World {
23-
monsters: StructOf<Dense<Monster>>,
24-
corpses: StructOf<Dense<Corpse>>,
22+
pub struct World {
23+
pub monsters: StructOf<Dense<Monster>>,
24+
pub corpses: StructOf<Dense<Corpse>>,
2525
}
2626

2727
fn main() {

examples/dynamic.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use stecs::prelude::*;
22

3-
struct World {
4-
units: StructOf<Dense<Unit>>,
3+
pub struct World {
4+
pub units: StructOf<Dense<Unit>>,
55
}
66

77
#[derive(Debug, Clone)]
8-
struct Poisoned {
9-
time: f32,
8+
pub struct Poisoned {
9+
pub time: f32,
1010
}
1111

1212
#[derive(SplitFields)]
1313
#[split(debug, clone)]
14-
struct Unit {
15-
name: String,
14+
pub struct Unit {
15+
pub name: String,
1616
}
1717

1818
fn main() {

examples/full.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22
use stecs::prelude::*;
33

44
#[derive(Clone)] // `StructOf` implements Clone if possible
5-
struct GameWorld {
6-
units: StructOf<Dense<Unit>>, // UnitStructOf<DenseFamily>,
7-
corpses: StructOf<Dense<Corpse>>, // CorpseStructOf<DenseFamily>,
8-
particles: StructOf<Dense<Particle>>, // ParticleStructOf<DenseFamily>,
5+
pub struct GameWorld {
6+
pub units: StructOf<Dense<Unit>>, // UnitStructOf<DenseFamily>,
7+
pub corpses: StructOf<Dense<Corpse>>, // CorpseStructOf<DenseFamily>,
8+
pub particles: StructOf<Dense<Particle>>, // ParticleStructOf<DenseFamily>,
99
}
1010

1111
#[derive(SplitFields, Debug)]
1212
#[split(debug)] // derive `Debug` for the `UnitRef` generated struct
13-
struct Unit {
14-
pos: (f32, f32),
15-
health: f32,
16-
tick: usize,
17-
damage: Option<f32>,
13+
pub struct Unit {
14+
pub pos: (f32, f32),
15+
pub health: f32,
16+
pub tick: usize,
17+
pub damage: Option<f32>,
1818
}
1919

2020
#[derive(SplitFields)]
21-
struct Corpse {
21+
pub struct Corpse {
2222
// Nest `Unit` to efficiently store the fields and to refer to them directly in the queries.
2323
// But you can still access the whole `Unit` as a single component.
2424
#[split(nested)]
25-
unit: Unit,
26-
time: f32,
25+
pub unit: Unit,
26+
pub time: f32,
2727
}
2828

2929
#[derive(SplitFields, Debug)]
3030
#[split(clone)] // implement clone method for the `ParticleRef` generated struct to clone the data into a `Particle`
31-
struct Particle {
32-
pos: (f32, f32),
33-
time: f32,
31+
pub struct Particle {
32+
pub pos: (f32, f32),
33+
pub time: f32,
3434
}
3535

3636
fn main() {

examples/generics.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
use stecs::prelude::*;
22

3-
struct World<'a> {
4-
units: StructOf<Dense<Unit<'a>>>,
3+
pub struct World<'a> {
4+
pub units: StructOf<Dense<Unit<'a>>>,
55
}
66

77
#[derive(SplitFields)]
88
#[split(debug, clone)]
9-
struct Position<F: 'static> {
10-
x: F,
11-
y: F,
9+
pub struct Position<F: 'static> {
10+
pub x: F,
11+
pub y: F,
1212
}
1313

1414
#[derive(SplitFields)]
1515
#[split(debug, clone)]
16-
struct Unit<'a> {
16+
pub struct Unit<'a> {
1717
#[split(nested)]
18-
position: Position<f32>,
19-
name: &'a str,
18+
pub position: Position<f32>,
19+
pub name: &'a str,
2020
}
2121

2222
fn main() {

examples/mutations.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
use stecs::prelude::*;
22

3-
struct World {
4-
blocks: StructOf<Dense<Block>>,
3+
pub struct World {
4+
pub blocks: StructOf<Dense<Block>>,
55
}
66

77
#[derive(SplitFields)]
88
#[split(debug)]
9-
struct Position {
10-
x: i64,
9+
pub struct Position {
10+
pub x: i64,
1111
}
1212

1313
#[derive(SplitFields)]
1414
#[split(debug)]
15-
struct Block {
15+
pub struct Block {
1616
#[split(nested)]
17-
position: Position,
18-
height: i64,
17+
pub position: Position,
18+
pub height: i64,
1919
}
2020

2121
fn main() {

src/storage/dense.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ unsafe impl<K: slotmap::Key> IdGenerator for DenseIdGenerator<K> {
9090
}
9191
}
9292

93-
/// Family of [`SlotMap<K, V>`] storages.
93+
/// Family of [`Dense<K, V>`] storages.
9494
pub struct DenseFamily<K: slotmap::Key>(std::marker::PhantomData<K>);
9595

9696
impl<K: slotmap::Key> StorageFamily for DenseFamily<K> {

src/storage/sparse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ unsafe impl<K: slotmap::Key> IdGenerator for DenseIdGenerator<K> {
9090
}
9191
}
9292

93-
/// Family of [`SlotMap<K, V>`] storages.
93+
/// Family of [`Sparse<K, V>`] storages.
9494
pub struct SparseFamily<K: slotmap::Key>(std::marker::PhantomData<K>);
9595

9696
impl<K: slotmap::Key> StorageFamily for SparseFamily<K> {

0 commit comments

Comments
 (0)