Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Doc/module style doc blocks for examples #4438

Conversation

themasch
Copy link
Contributor

@themasch themasch commented Apr 7, 2022

Objective

Provide a starting point for #3951, or a partial solution.
Providing a few comment blocks to discuss, and hopefully find better one in the process.

Solution

Since I am pretty new to pretty much anything in this context, I figured I'd just start with a draft for some file level doc blocks. For some of them I found more relevant details (or at least things I considered interessting), for some others there is less.

Changelog

  • Moved some existing comments from main() functions in the 2d examples to the file header level
  • Wrote some more comment blocks for most other 2d examples

TODO:

  • 2d/sprite_sheet, wasnt able to come up with something good yet
  • all other example groups...

Also: Please let me know if the commit style is okay, or to verbose. I could certainly squash these things, or add more details if needed.
I also hope its okay to raise this PR this early, with just a few files changed. Took me long enough and I dont wanted to let it go to waste because I lost motivation to do the whole thing. Additionally I am somewhat uncertain over the style and contents of the commets. So let me know what you thing please.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Apr 7, 2022
@IceSentry IceSentry added C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples and removed S-Needs-Triage This issue needs to be labelled labels Apr 7, 2022
@IceSentry
Copy link
Contributor

Your commit style is fine, we always squash the PR in a single commit using the PR title+description as the commit message so it doesn't matter how you commit while working on it.

@@ -1,3 +1,32 @@
//! This example collects a list of all contributors to the bevy source code and renders a bouncing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I would prefer if comments explaining a specific system were directly on that system and not all at the top. I think the top level doc should just be a short explanation of what it is. I would start with having the same short description found in the examples README

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree here :)

@alice-i-cecile alice-i-cecile self-requested a review April 7, 2022 15:41
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks! I agree with IceSentry: we can keep the "module-level" comments pretty terse to start.

More detailed explanation (such as "why do we add LogPlugin) belongs with that code, because it's a) more helpful to users there and b) less likely to go out of sync.

@themasch
Copy link
Contributor Author

themasch commented Apr 8, 2022

First, thanks for you fast and helpful feedback! I really dont know what I was thinking when doing the contributors comment/novel.

Your commit style is fine, we always squash the PR in a single commit using the PR title+description as the commit message so it doesn't matter how you commit while working on it.

Great, thanks!

I think the top level doc should just be a short explanation of what it is. I would start with having the same short description found in the examples README

I agree with IceSentry: we can keep the "module-level" comments pretty terse to start.

I agree that especially the contributors one is way to big, and really need to be split up shortened. But on the other hand, I think that the description in the examples README list is a bit to terse for a file doc. I think, especially in examples, a comment should add a little bit more than just "sprite.rs renders a sprite".

Maybe a way between those extremes would be useful? Do you thing the comments for mesh2d.rs and mesh2d_manual.rs are okay?

I will rework the changes by (re-)moving details and keeping the file level doc block terse.

@alice-i-cecile
Copy link
Member

Maybe a way between those extremes would be useful? Do you thing the comments for mesh2d.rs and mesh2d_manual.rs are okay?

I really like these comments :) They strike a nice balance, and provide some essential context on the examples.

@IceSentry
Copy link
Contributor

IceSentry commented Apr 8, 2022

Oh, yeah, I was just suggesting the README comments as a starting point. I definitely agree that more detail is necessary. My issue was specifically about the comments explaining specific systems not being directly next to the system,

@cart
Copy link
Member

cart commented Apr 8, 2022

I'm on board with this general approach. Whenever y'all think this is ready, feel free to merge!

@themasch themasch force-pushed the doc/module-style-doc-blocks-for-examples branch from 4ba0af0 to cf66375 Compare April 17, 2022 11:34
@themasch themasch marked this pull request as ready for review April 17, 2022 15:45
@themasch
Copy link
Contributor Author

So, I think this is ready for review/feedback. All examples should have comments, I used the ones from the readme if I was not able to come up with something short and better (most of them), used existing comments where they existed.

@alice-i-cecile
Copy link
Member

@bevyengine/docs-team can I get another set of eyes on this? :)

Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look at everything in detail, but it looks good to me except a couple of nitpicks

@@ -1,8 +1,21 @@
//! Simple benchmark to test per-entity draw overhead
//!
//! To a realistic performance result, run this in release mode.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like there's a missing word here. "To see a" or "To get a" or something like that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! To a realistic performance result, run this in release mode.
//! To measure performance realistically, be sure to run this in release mode.

@@ -1,3 +1,8 @@
//! A simple way to view glTF models with Bevy.
//! Just run `cargo run --release --example scene_viewer -- /path/to/model.gltf#Scene0`,
Copy link
Contributor

@IceSentry IceSentry Apr 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the -- is necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. Just tested this, and - at least with 1.60 on windows - cargo run seems to pass additional paramters to the target binary.
I'll remove all -- from cargo runs in the examples.

@@ -1,3 +1,5 @@
//! An empty application (does nothing)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love that this example exists, but that's not this PR's fault.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want me to delete it?
Not sure if thats something that should be done in this context?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to say that this should be done in a separate PR, yeah.

@@ -1,3 +1,5 @@
//! Allows reflection with trait objects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't terribly descriptive; but IMO we should tackle this as part of a push to properly document and explain bevy_reflect instead.

@@ -1,6 +1,7 @@
//! This example illustrates loading and saving scenes from files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could really use a brief explanation of what a "scene" is in Bevy.

Copy link
Contributor Author

@themasch themasch Apr 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me to add that, I'd need to understand that myself 😅. From what I understand, a Scene is a newtype wrapper around a World so we can put complete worlds - for example loaded from gltf assets - into our main world. That works by copying all components from the scene to the world its spawned in when the command is executed. Therefor, it does not really 'mount' other worlds into our app.world, it just uses the container to spawn a coupled set of components/entities into it?

a Scene is a set of entites that can be loaded from an asset and added to our world.?

Copy link
Member

@alice-i-cecile alice-i-cecile Apr 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's about the right idea. They're effectively "ECS data, but on disk". We can clean this up later :)

@@ -1,3 +1,5 @@
//! A compute shader simulating Conway's Game of Life
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a compute shader? ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a sentence to add some context.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Great work; and we can build on these further.

In general, I think these could benefit from having a bit more "background explanation" about the topics they're covering, but I'm fine to address those in follow-up PRs.

IMO we should clean up the few typos, and then merge this.

@themasch themasch force-pushed the doc/module-style-doc-blocks-for-examples branch from 9afa163 to 16ed993 Compare April 18, 2022 10:23
@themasch
Copy link
Contributor Author

Thanks for the quick feedback, I tried to address all points.

@alice-i-cecile
Copy link
Member

@bevyengine/docs-team + @Nilirad can I have another review or two on this? I'd like to get this in and start enforcing it as a standard.

Copy link
Contributor

@Nilirad Nilirad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doing this review by pieces since the PR is quite big. I reached the load_gltf example. I mostly did consistency checks and, in a couple of cases, I suggested a longer, more specific suggestion.

@@ -1,3 +1,8 @@
//! This example shows how to manually render 2d items using "mid level render apis" with a custom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! This example shows how to manually render 2d items using "mid level render apis" with a custom
//! This example shows how to manually render 2d items using "mid level render apis" with a custom

Double space.

Comment on lines 3 to 4
//! It doesn't use the [`Material2d`] abstraction, but changes the vertex buffer to include vertex color
//! Check out the "mesh2d" example for simpler / higher level 2d meshes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! It doesn't use the [`Material2d`] abstraction, but changes the vertex buffer to include vertex color
//! Check out the "mesh2d" example for simpler / higher level 2d meshes
//! It doesn't use the [`Material2d`] abstraction, but changes the vertex buffer to include vertex color.
//! Check out the "mesh2d" example for simpler / higher level 2d meshes.

Period at the end of sentence.

@@ -9,6 +11,8 @@ fn main() {

fn setup(mut commands: Commands) {
commands.spawn_bundle(OrthographicCameraBundle::new_2d());

// Since this Sprite is not generated from an image, we have to specify its size in `custom_size`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Since this Sprite is not generated from an image, we have to specify its size in `custom_size`.
// Since this `Sprite` is not generated from an image, we have to specify its size in `custom_size`.

Monospace consistency.

@@ -1,3 +1,5 @@
//! Demonstrates rotating entities in 2D with quaternions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! Demonstrates rotating entities in 2D with quaternions.
//! Demonstrates rotating entities in 2D using quaternions.

Just my opinion, feel free to skip if using “with” is sufficient.

@@ -1,7 +1,8 @@
//! In this example we generate a new texture atlas (sprite sheet) from a folder containing
//! individual sprites
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! individual sprites
//! individual sprites.

Sentence period.

@@ -1,3 +1,5 @@
//! Simple 3D scene with basic shapes and lighting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I would think about changing the description into something less generic, that makes the reader expect more what they are about to see, since the focus of the example is on the scene itself; maybe something like:

A simple 3D scene with light shining over a cube sitting on a plane.

@@ -1,3 +1,5 @@
//! Illustrates various lighting options in a simple scene
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! Illustrates various lighting options in a simple scene
//! Illustrates various lighting options in a simple scene.

Sentence period.

@@ -1,3 +1,5 @@
//! Illustrates various lighting options in a simple scene
Copy link
Contributor

@Nilirad Nilirad May 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the description should talk about the fact that there are used different light types (point, directional, ...) and different colors, instead of simply stating “various lighting options”.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sounds good. I'll try to come up with something more helpful!

@@ -1,3 +1,5 @@
//! Loads and renders a gltf file as a scene
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! Loads and renders a gltf file as a scene
//! Loads and renders a glTF file as a scene.

This is the capitalization that Khronos uses. If one is referring to the file extension instead, they should write “.gltf file” instead. It is ok to say “glTF file” since it is another wording for “file with glTF format”.

I also added the period.

@@ -1,3 +1,10 @@
//! Example to show text rendering with moving, rotating and scaling text.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! Example to show text rendering with moving, rotating and scaling text.
//! Shows text rendering with moving, rotating and scaling text.

Saying it is an example doesn't convey any new or useful information.

@themasch
Copy link
Contributor Author

themasch commented May 1, 2022

Thanks for the annotations, @Nilirad! I went through the list and added periods where they where missing in the header comment. I did not fix punctuation for all existing comments (yet), as I think that would increase the pull request size even more.
If you want me to tackle this as well, let me know.

@themasch themasch force-pushed the doc/module-style-doc-blocks-for-examples branch from c796c38 to cbc2470 Compare May 15, 2022 08:11
@themasch
Copy link
Contributor Author

Thanks again @Nilirad, I copied all your suggestions. At least I hope I got them all correct, at this point I doubt my ability to do even that.
Sorry for this terrible attempt, I guess I should have left this to someone more capable.

Anyhow, I rebased on the current main branch, as there was a merge conflict (2d/rect.rs got deleted). A few new examples have been added in the meantime, some of them without commets, so I tried to add at least a basic one. Basically longer versions of the file name 😕.

@Nilirad
Copy link
Contributor

Nilirad commented May 16, 2022

You did a great job with this PR! The amount of files made it a gigantic task, and that's normal to make some mistakes. That's why reviews are fundamental.


I'll do now a quick final pass to ensure there aren't misplaced descriptions. I'll ignore typos, grammar, punctuation or form so we can merge it ASAP.

Copy link
Contributor

@Nilirad Nilirad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are no grave mistakes. Thank you for accomplishing this task @themasch, and congratulations for your first merged contribution! 🎉

@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request May 16, 2022
# Objective

Provide a starting point for #3951, or a partial solution. 
Providing a few comment blocks to discuss, and hopefully find better one in the process. 

## Solution

Since I am pretty new to pretty much anything in this context, I figured I'd just start with a draft for some file level doc blocks. For some of them I found more relevant details (or at least things I considered interessting), for some others there is less. 

## Changelog

- Moved some existing comments from main() functions in the 2d examples to the file header level
- Wrote some more comment blocks for most other 2d examples

TODO: 
- [x] 2d/sprite_sheet, wasnt able to come up with something good yet 
- [x] all other example groups...


Also: Please let me know if the commit style is okay, or to verbose. I could certainly squash these things, or add more details if needed. 
I also hope its okay to raise this PR this early, with just a few files changed. Took me long enough and I dont wanted to let it go to waste because I lost motivation to do the whole thing. Additionally I am somewhat uncertain over the style and contents of the commets. So let me know what you thing please.
@bors bors bot changed the title Doc/module style doc blocks for examples [Merged by Bors] - Doc/module style doc blocks for examples May 16, 2022
@bors bors bot closed this May 16, 2022
robtfm pushed a commit to robtfm/bevy that referenced this pull request May 17, 2022
# Objective

Provide a starting point for bevyengine#3951, or a partial solution. 
Providing a few comment blocks to discuss, and hopefully find better one in the process. 

## Solution

Since I am pretty new to pretty much anything in this context, I figured I'd just start with a draft for some file level doc blocks. For some of them I found more relevant details (or at least things I considered interessting), for some others there is less. 

## Changelog

- Moved some existing comments from main() functions in the 2d examples to the file header level
- Wrote some more comment blocks for most other 2d examples

TODO: 
- [x] 2d/sprite_sheet, wasnt able to come up with something good yet 
- [x] all other example groups...


Also: Please let me know if the commit style is okay, or to verbose. I could certainly squash these things, or add more details if needed. 
I also hope its okay to raise this PR this early, with just a few files changed. Took me long enough and I dont wanted to let it go to waste because I lost motivation to do the whole thing. Additionally I am somewhat uncertain over the style and contents of the commets. So let me know what you thing please.
exjam pushed a commit to exjam/bevy that referenced this pull request May 22, 2022
# Objective

Provide a starting point for bevyengine#3951, or a partial solution. 
Providing a few comment blocks to discuss, and hopefully find better one in the process. 

## Solution

Since I am pretty new to pretty much anything in this context, I figured I'd just start with a draft for some file level doc blocks. For some of them I found more relevant details (or at least things I considered interessting), for some others there is less. 

## Changelog

- Moved some existing comments from main() functions in the 2d examples to the file header level
- Wrote some more comment blocks for most other 2d examples

TODO: 
- [x] 2d/sprite_sheet, wasnt able to come up with something good yet 
- [x] all other example groups...


Also: Please let me know if the commit style is okay, or to verbose. I could certainly squash these things, or add more details if needed. 
I also hope its okay to raise this PR this early, with just a few files changed. Took me long enough and I dont wanted to let it go to waste because I lost motivation to do the whole thing. Additionally I am somewhat uncertain over the style and contents of the commets. So let me know what you thing please.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

Provide a starting point for bevyengine#3951, or a partial solution. 
Providing a few comment blocks to discuss, and hopefully find better one in the process. 

## Solution

Since I am pretty new to pretty much anything in this context, I figured I'd just start with a draft for some file level doc blocks. For some of them I found more relevant details (or at least things I considered interessting), for some others there is less. 

## Changelog

- Moved some existing comments from main() functions in the 2d examples to the file header level
- Wrote some more comment blocks for most other 2d examples

TODO: 
- [x] 2d/sprite_sheet, wasnt able to come up with something good yet 
- [x] all other example groups...


Also: Please let me know if the commit style is okay, or to verbose. I could certainly squash these things, or add more details if needed. 
I also hope its okay to raise this PR this early, with just a few files changed. Took me long enough and I dont wanted to let it go to waste because I lost motivation to do the whole thing. Additionally I am somewhat uncertain over the style and contents of the commets. So let me know what you thing please.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants