bevy/crates/bevy_reflect/bevy_reflect_derive/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
..
impls bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
container_attributes.rs Support multiple #[reflect]/#[reflect_value] + improve error messages (#6237) 2022-10-17 14:38:56 +00:00
derive_data.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
documentation.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
enum_utility.rs Add reflect(skip_serializing) which retains reflection but disables automatic serialization (#5250) 2022-09-19 16:12:10 +00:00
field_attributes.rs Add reflect(skip_serializing) which retains reflection but disables automatic serialization (#5250) 2022-09-19 16:12:10 +00:00
from_reflect.rs bevy_reflect: Reflect enums (#4761) 2022-08-02 22:14:41 +00:00
lib.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
reflect_value.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
registration.rs Add reflect(skip_serializing) which retains reflection but disables automatic serialization (#5250) 2022-09-19 16:12:10 +00:00
trait_reflection.rs bevy_reflect: Added get_boxed method to reflect_trait (#4120) 2022-05-20 13:31:49 +00:00
type_uuid.rs Clippy improvements (#4665) 2022-05-31 01:38:07 +00:00
utility.rs bevy_reflect: Improve serialization format even more (#5723) 2022-09-20 19:38:18 +00:00