bsn: improve docs and add tests#24464
Conversation
|
|
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
| //! both would supply a [`FromTemplate`] impl and conflict. | ||
| //! You still have access to a default constructor of sorts though: the derive generates a companion | ||
| //! `YourTypeTemplate` struct that implements `Default`, so `YourTypeTemplate::default()` serves the same purpose. | ||
| //! For this reason, there is a custom "derive" which isn't actually a Trait, called [`VariantDefaults`](bevy_ecs::VariantDefaults) |
There was a problem hiding this comment.
This is very confusing to read; I think we're leaking implementation details here.
There was a problem hiding this comment.
Perhaps, tho it feels like it needs to, otherwise people will go looking for the VariantDefaults trait which is just not a thing. I've tried re-wording it a bit.
| //! | ||
| //! For a quick rundown on how to read and write BSN syntax, | ||
| //! see the docs for [`bsn!`]. | ||
| //! We plan on making "conditional scenes" easier to define in future releases. |
There was a problem hiding this comment.
Issue link would be nice, but I don't think one currently exists?
alice-i-cecile
left a comment
There was a problem hiding this comment.
A fair bit of clean up to do, but a marked improvement.
Moving from "inheritance" to "caching" has clarified a tremendous number of things for me.
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
|
Note: This PR does not include docs for any of the new features and syntax @cart made PRs for after I un-Draft-ed this. |
There was a problem hiding this comment.
Fixed a failing test in the last commit: I stared at it for quite a bit and came to the conclusion that it was simply asserting the wrong thing. That should be passing CI soon. IMO we should merge this in ASAP, and refine further in follow-up (such as for those new features).
Trashtalk217
left a comment
There was a problem hiding this comment.
Some notes, take what you need.
| //! Enums are special-cased to allow for better implicit defaults: [`bsn!`] requires that enums have defaults for all variant arms, not just the type as a whole. | ||
| //! | ||
| //! When [`bsn!`] encounters a Enum, it will try to get the default value for the variant using static methods like `default_{variant_lower}`. | ||
| //! To help with setting up these methods, theres a pseudod-`derive` called [`VariantDefaults`](bevy_ecs::VariantDefaults). |
There was a problem hiding this comment.
| //! To help with setting up these methods, theres a pseudod-`derive` called [`VariantDefaults`](bevy_ecs::VariantDefaults). | |
| //! To help with setting up these methods, theres a pseudo-`derive` called [`VariantDefaults`](bevy_ecs::VariantDefaults). |
| //! [`Scene`], so patches from multiple sources merge into a single [`ResolvedScene`]. | ||
| //! | ||
| //! For programmatic patching outside of [`bsn!`], see the [`PatchFromTemplate`] and | ||
| //! For programmatic patching outside of [`bsn!`], see the [`PatchFromTemplate`] and |
There was a problem hiding this comment.
| //! For programmatic patching outside of [`bsn!`], see the [`PatchFromTemplate`] and | |
| //! For programmatic patching outside of [`bsn!`], see the [`PatchFromTemplate`] and |
| /// | `@MySceneComp { @prop: val }` | Include a [`SceneComponent`] with a `prop` field, passed to this components scene function | | ||
| /// | `@MySceneComp { name: val }` | Include a [`SceneComponent`] with a normal field, works the same as it does for normal components | | ||
| /// | `@MySceneComp { @prop: val1, name: val2 }` | Include a [`SceneComponent`] with both a `prop` and a field | | ||
| /// | `:"scene.bsn"` | <div class="warning">Asset format no yet implemented!</div> Include a cached scene asset file | |
There was a problem hiding this comment.
| /// | `:"scene.bsn"` | <div class="warning">Asset format no yet implemented!</div> Include a cached scene asset file | | |
| /// | `:"scene.bsn"` | <div class="warning">Asset format not yet implemented!</div> Include a cached scene asset file | |
| /// | `on(my_observer)` | Attaches an entity [`observer`] for the [`EntityEvent`] `Ev` to this entity. In this example, using a function | | ||
| /// | **Relationships** | | | ||
| /// | `Children []` | Spawns each entry as a child of this entity, see **Scene Lists** below for details | | ||
| /// | `ChildOf(entity)` | Makes **this** entity a child of `entity`, accepts a [`Entity`] or a `#Name` reference ([`EntityTemplate`]) | |
There was a problem hiding this comment.
| /// | `ChildOf(entity)` | Makes **this** entity a child of `entity`, accepts a [`Entity`] or a `#Name` reference ([`EntityTemplate`]) | | |
| /// | `ChildOf(entity)` | Makes **this** entity a child of `entity`, accepts an [`Entity`] or a `#Name` reference ([`EntityTemplate`]) | |
| /// | `1.1` or `-0.1` or `1.` or `-2.` | Float | Floating point number, common types: `f32`, `f64` | | ||
| /// | `true` or `false` | Bool | Boolean, type: [`bool`] | | ||
| /// | `"somename"` | String | Text, types: `String` or `&'static str` | | ||
| /// | `"mypicture.png"` | Asset path | Asset, when used in a field which expects a [`Handle`] to the matching `Asset` type | |
There was a problem hiding this comment.
I saw another import that just used "goblin" instead of "goblin.png" which is correct?
| /// | `true` or `false` | Bool | Boolean, type: [`bool`] | | ||
| /// | `"somename"` | String | Text, types: `String` or `&'static str` | | ||
| /// | `"mypicture.png"` | Asset path | Asset, when used in a field which expects a [`Handle`] to the matching `Asset` type | | ||
| /// | `some(1)` | Function call | Calls a function with the provided arguments | |
There was a problem hiding this comment.
| /// | `some(1)` | Function call | Calls a function with the provided arguments | | |
| /// | `some_function(1)` | Function call | Calls a function with the provided arguments | |
There was a problem hiding this comment.
Because some(1) might be confused with Some.
Objective
Improve documentation of bevy_scene/bsn.
Rendered: https://share.yadamiel.com/docs/doc/bevy/scene/index.html
Closes: #24299
Closes: #24540
Closes: #24541
Solution
This PR depends on/includes changes from
Docs changes (approx)
Inheritanceconcept in favour of cachingTesting
cargo doc -Zrustdoc-mergeable-info -p bevy_scene --liblocally works fineTodo