Repository navigation
Conversation
|
Here's a visual of what I changed: New docs: new_docs.mp4Old docs: old_docs.mp4 |
| # Snippets in this book are library code (cdylib entry points, #[godot_api] impls, ...) and | ||
| # depend on the `godot` crate, so none of them can run on play.rust-lang.org. Without this, | ||
| # mdbook silently wraps every Rust block in a hidden `fn main() { ... }`, which the "show | ||
| # hidden lines" eye icon then reveals as if it were real code. Explicit `# ` hidden lines | ||
| # still work as usual. |
There was a problem hiding this comment.
That's a lot of words used while shorter one-line sentence could do a job just fine.
| // Anchor names may be opened and closed more than once; mdbook concatenates the regions and | ||
| // hides everything in between. That is how a block can show e.g. the `impl` header and one | ||
| // method without the other methods. |
There was a problem hiding this comment.
why do you describe something which is included in mdbook documentation https://wofwca.github.io/mdBook/format/mdbook.html#including-portions-of-a-file?
There was a problem hiding this comment.
Sometimes I leave slop in. Planning to remove.
| // Complete source for the Hello World tutorial. Every code block in | ||
| // src/intro/hello-world.md includes one of the anchors below. |
There was a problem hiding this comment.
what does this comment is supposed to convey?
| // ANCHOR_END: physics-process | ||
| // In GDScript, this would be: | ||
| // rotation += angular_speed * delta | ||
|
|
||
| // ANCHOR: physics-process | ||
| // GDScript code: | ||
| // | ||
| // rotation += angular_speed * delta | ||
| // var velocity = Vector2.UP.rotated(rotation) * speed | ||
| // position += velocity * delta | ||
|
|
||
| let radians = (self.angular_speed * delta) as f32; | ||
| self.base_mut().rotate(radians); | ||
| // The 'rotate' method requires a f32, | ||
| // therefore we convert 'self.angular_speed * delta' which is a f64 to a f32 | ||
| // ANCHOR_END: rotate |
There was a problem hiding this comment.
Seems like the best way around this is two have two separate Rust files or foregoing the hidden lines feature on one of the blocks. lmk what you think.
There was a problem hiding this comment.
I think two files might be okay, people might want to copy-paste them
| // therefore we convert 'self.angular_speed * delta' which is a f64 to a f32 | ||
| } | ||
| } | ||
| {{#rustdoc_include code/hello-world.rs:rotate}} |
There was a problem hiding this comment.
Personally I would just inline this one example (or split existing one into two if somebody insists). Additionally, rotate section is misleading - the example showcases usage of virtual method physics_process.
and a small update can be made – for a long time one can use delta: f32 directly in *process methods.
There was a problem hiding this comment.
Will change rotate to something else. If you're okay with losing the hidden context here, I'd be okay with inlining too (unless you want to copy and paste the entirety of hello-world.rs into the readme just for it).
New to godot and haven't really ever contributed to a large codebase personally or professionally before. Thanks for the review!
|
Created two new files. One with the updated physics function and one without. This inherently solves the I'm testing this on |
It does 🙂 godot-rust/gdext#1110 |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| // Note: This code contains the updated version of the physics_process function. |
There was a problem hiding this comment.
firstly: it doesn't
secondly: why this note?
There was a problem hiding this comment.
Honestly the top comment is comment slop. Removed. I wrote the note to orient myself in case I'm copy and pasting from the docs website directly into a file.
Edit: Seems like the top comment is needed for the CI. lmk if you think the note is appropriate. If not told anything, just gonna keep it in 🤷
There was a problem hiding this comment.
this info should be over the edited physics_process function, so the context is obvious for reader (as something along the lines of "in physics_process both f32 or f64 can be used for delta")
There was a problem hiding this comment.
I moved where the note is as well as added that little pointer in a comment.
I need to give my error messages a closer check!. Thanks :) I'll push a change in a little bit. |
10a5309 to
ef96b99
Compare
|
Any reason why |
|
Not really, feel free to use |
Also changed #[godot_api]
impl Player {
#[func]
fn increase_speed(&mut self, amount: f32) {
self.speed += amount;
self.signals().speed_increased().emit();
}
#[signal]
fn speed_increased();
} |
|
This looking good? Can condense the commits into one. |
|
Why do you close this? |
|
I felt like it wasn't going to get merged. No feedback in a week demoralized me. |
I don't even know what to answer here. People have lives, this is a project made by volunteers in their free time, and the eye button in a book might not be on everyone's top priority 24/7. I appreciate your work but a bit of patience isn't unreasonable. It's not like this PR has been sitting for months or years, a very common thing in open-source btw. In fact, this PR has already gotten plenty of attention by two different maintainers. Up to you how you'd like to proceed. |
|
There is truth to your message. I appreciate even being able to program a game in Rust. I don't see why it can't stay open for a while. |

Why
When I read through a rust book, I like to click on the little eye icon to see how a block of code fits into the entirety of the program. I found myself confused after reading through the Hello World example.
Problem
The current behavior of the eye button wraps the block of code in a main function call. This is not verbose enough and confusing in my opinion. Also, none of the playground examples compile.
Proposed Changes
lib.rsfileMore details about the changes
The play button is removed by adding the block below to
book.tomlAs for showing code when the eye icon is pressed, I created a file at
src/intro/code/hello-world.rsthat has anchors placed in it, controlling what code is shown. I removed the linefn init(base: Base<Sprite2D>) -> Self { /* as before */ }from being mentioned as the user could simply click the eye and see the implementation. Finally, I added an admonish tip to click the eye before theRust entry pointblock.AI Usage
I used Claude Opus 5 in this PR. Claude stitched together the code blocks and placed most of the anchor points in
src/intro/code/hello-world.rs. I modified the anchor points to remain loyal to the original rust blocks.Testing
Using Godot 4.7.1, I saw
icon.svgmoving in a circle from the code insrc/intro/code/hello-world.rswhen running the scene. I have not tested whether theCustom Rust APIsblock functions.Final Notes
If anything could be changed, let me know.