MrGVSV / bevy_proto

Create config files for entities in Bevy
Other
239 stars 25 forks source link

document public items, fix doc tests #14

Closed B-Reif closed 2 years ago

B-Reif commented 2 years ago

This PR adds a lint to warn for missing docs, adds some documentation for public items that didn't have any, and fixes examples that were failing in rustdoc tests.

B-Reif commented 2 years ago

One downside to our current approach is that the blocks in the README aren't tested by cargo test, so it's possible for them to be incorrect / out of date. I'm not sure what the best approach is to solving that.

MrGVSV commented 2 years ago

One downside to our current approach is that the blocks in the README aren't tested by cargo test, so it's possible for them to be incorrect / out of date. I'm not sure what the best approach is to solving that.

That's true. Maybe we can do something like: https://github.com/rust-lang/cargo/issues/383#issuecomment-720873790 in lib.rs?

B-Reif commented 2 years ago

Sure, I'll give it a go

B-Reif commented 2 years ago

@MrGVSV Two of the doc tests for the README are failing whenever we try to get EntityCommands from ProtoCommands:

error[E0623]: lifetime mismatch
  --> src\lib.rs:397:46
   |
22 |     fn insert_self(&self, proto_commands: &mut ProtoCommands, asset_server: &Res<AssetServer>) {
   |                                                ------------- this type is declared with multiple lifetimes...
23 |         let handle: Handle<Image> = asset_server.load(self.texture_path.as_str());
24 |         let entity_commands = proto_commands.raw_commands();
   |                                              ^^^^^^^^^^^^ ...but data with one lifetime flows into the other here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0623`.
Couldn't compile the test.

I'm not sure how to resolve this. It seems like this error pops up whenever raw_commands is invoked.

MrGVSV commented 2 years ago

@MrGVSV Two of the doc tests for the README are failing whenever we try to get EntityCommands from ProtoCommands:

error[E0623]: lifetime mismatch
  --> src\lib.rs:397:46
   |
22 |     fn insert_self(&self, proto_commands: &mut ProtoCommands, asset_server: &Res<AssetServer>) {
   |                                                ------------- this type is declared with multiple lifetimes...
23 |         let handle: Handle<Image> = asset_server.load(self.texture_path.as_str());
24 |         let entity_commands = proto_commands.raw_commands();
   |                                              ^^^^^^^^^^^^ ...but data with one lifetime flows into the other here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0623`.
Couldn't compile the test.

I'm not sure how to resolve this. It seems like this error pops up whenever raw_commands is invoked.

Hm, I wonder if it's because of the lifetime on EntityCommands here: https://github.com/MrGVSV/bevy_proto/blob/22c84e321586ce743cc39c43e412177cef6cb099/src/data.rs#L341-L343 Does eliding the 'p lifetime on the references resolve the issue?

If not, we could maybe try making 'p: 'a? Not sure if that would fix it though...

B-Reif commented 2 years ago

Does eliding the 'p lifetime on the references resolve the issue?

Yes, that did it!