bevy/crates/bevy_reflect/src
Gino Valente a658bfef19 bevy_reflect: Reflect doc comments (#6234)
# Objective

Resolves #6197

Make it so that doc comments can be retrieved via reflection.

## Solution

Adds the new `documentation` feature to `bevy_reflect` (disabled by default).

When enabled, documentation can be found using `TypeInfo::doc` for reflected types:

```rust
/// Some struct.
///
/// # Example
///
/// ```ignore
/// let some_struct = SomeStruct;
/// ```
#[derive(Reflect)]
struct SomeStruct;

let info = <SomeStruct as Typed>::type_info();
assert_eq!(
    Some(" Some struct.\n\n # Example\n\n ```ignore\n let some_struct = SomeStruct;\n ```"),
    info.docs()
);
```

### Notes for Reviewers

The bulk of the files simply added the same 16 lines of code (with slightly different documentation). Most of the real changes occur in the `bevy_reflect_derive` files as well as in the added tests.

---

## Changelog

* Added `documentation` feature to `bevy_reflect`
* Added `TypeInfo::docs` method (and similar methods for all info types)
2022-10-18 13:49:57 +00:00
..
enums bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
impls Impl Reflect for PathBuf and OsString (#6193) 2022-10-08 17:02:21 +00:00
serde bevy_reflect: Improve serialization format even more (#5723) 2022-09-20 19:38:18 +00:00
array.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
fields.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
lib.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
list.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
map.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
path.rs Make arrays behave like lists in reflection (#5987) 2022-09-27 18:11:38 +00:00
reflect.rs bevy_reflect: Update Reflection documentation (#5841) 2022-09-02 16:17:45 +00:00
std_traits.rs add #[reflect(Default)] to create default value for reflected types (#3733) 2022-05-03 19:20:13 +00:00
struct_trait.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
tuple_struct.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
tuple.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
type_info.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
type_registry.rs Add reflect(skip_serializing) which retains reflection but disables automatic serialization (#5250) 2022-09-19 16:12:10 +00:00
type_uuid.rs re-enable #[derive(TypeUuid)] for generics (#4118) 2022-04-26 19:41:25 +00:00
utility.rs bevy_reflect: Improve serialization format even more (#5723) 2022-09-20 19:38:18 +00:00