-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
adds doc tests to Godot Ext #139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to get some more missing documentation!
And having more info on how to use GodotExt
is nice, doctests are nice but i am so bad at figuring out how to write them properly lol.
godot-core/src/bind.rs
Outdated
/// | ||
/// | ||
/// Note that you have to implement init otherwise you won't be able to call new or any | ||
/// other methods from gdscript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing period here, and some other places too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
godot-core/src/log.rs
Outdated
@@ -4,6 +4,7 @@ | |||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | |||
*/ | |||
|
|||
/// Throws a godot warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this and the others, as they are equivalent to some godot-functions, you could add a
/// _Godot equivalent: @GlobalScope.push_warning()_
at the bottom. We do this in some other places too to make it easier for people familiar with godot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
godot-core/src/log.rs
Outdated
@@ -75,6 +78,7 @@ pub use crate::{godot_error, godot_print, godot_script_error, godot_warn}; | |||
use crate::builtin::{StringName, Variant}; | |||
use crate::sys::{self, GodotFfi}; | |||
|
|||
/// prints to the godot console, it's use is to be used by the godot_print! macro |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording is a little clunky here, maybe just drop "it's use is to be" and have it just say "used by the godot_print! macro".
Also it should be "its use" not "it's use".
I think you can also link to the godot_print
macro in the doc here?
Also, missing capitalization and period.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes that's better, thanks I'm not a native english speaker so this is a big help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this pull request 🙂
Maybe some general suggestions:
- Please pay attention to use full English sentences even in documentation. That means: capitalization, full stops or punctuation in general.
- For code examples, make sure they are properly indented and formatted (rustfmt).
- In godot-rust, you can typically not use
```
in doctests, because the Godot engine is needed for a lot of things to work. Instead, use```no_run
. - Run
./check.sh
locally to make sure some of the basic checks pass. See Contributing.md. - Pay attention to details like:
- surrounding library symbols with single backticks whenever you refer to them from docs
- capitalizing names properly ("GDScript" and "Godot", not "gdscript" and "godot")
godot-core/src/bind.rs
Outdated
/// | ||
/// # Examples | ||
/// | ||
/// ## Basic Reference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called RefCounted
now (Reference
in Godot 3).
And what do you mean with "basic"? Maybe be explicit and say:
/// ## With `RefCounted` as a base class
godot-core/src/log.rs
Outdated
@@ -21,6 +22,7 @@ macro_rules! godot_warn { | |||
}; | |||
} | |||
|
|||
/// Throws a godot error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't throw an error (what does that even mean, there are no exceptions in Rust or GDScript?).
Instead, it prints one. Here, it would be interesting to see how it differentiates from godot_print
and godot_warn
.
The upstream Godot documentation can also be a good source of information, although in this particular case, the method doesn't exist as is.
Running it locally for me didn't cause any errors, did it for you? |
I didn't try, but I'd expect it to fail with doctests that need engine support. bors try |
tryBuild succeeded: |
Thank you for all the comments and pointers! i ran check.sh before pushing and it passed but bors try seems to have some fail checks :/ |
I initially thought about ```no_run` but seeing as cargo test --doc was passing I decided to leave it off, should I add it ? |
That's strange, it could mean that your doctests are not actually run. |
They are listed for sure cause they didn't run initially (i forgot a bracket somewhere) and then they started passing. |
I'm fixing some little things before i push on this PR again, taken comments into account and testing that what I write is actually correct. |
I'm running
definitely running and passing. just let me reread myself |
Okay, took all comments into account, ran check.sh successfully again, I'm ready for another review or merging ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As already mentioned by sayaks on Discord, this will soon be obsolete, as #136 is almost ready.
I don't think it makes sense to merge this PR now, as it would just introduce conflicts for #136 and would be immediately reverted (for example, bind.rs
is being removed by that PR). Instead, I would suggest:
- to move the
GodotExt
documentation you added to the#[derive(GodotClass)]
macro documentation, ingodot-macros/src/lib.rs
- to update it according to the new API in Virtual function dispatch #136 (should be relatively simple,
GodotExt
becomes<Base>Virtual
, e.g.RefCountedVirtual
) - to leave the print docs as-is, they are fine.
godot-core/src/bind.rs
Outdated
/// fn init(base : Base<Node>) -> Self { | ||
/// MyNode {base} | ||
/// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe run the examples through rustfmt:
/// fn init(base : Base<Node>) -> Self { | |
/// MyNode {base} | |
/// } | |
/// fn init(base: Base<Node>) -> Self { | |
/// MyNode { base } | |
/// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
running cargo fmt
or rustfmt godot-core/src/bind.rs
changes no file on my system, is that expected behaviour? I don't like to format by hand, my eyes are bad at this x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it probably doesn't format doc test i assume ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's an easy workaround, you remove /// from each line of your doctests and let cargo fmt do the work
godot-core/src/bind.rs
Outdated
/// #[godot_api] | ||
/// impl MyRef { | ||
/// #[func] | ||
/// pub fn hello_world(&mut self) { | ||
/// godot_print!("Hello World!") | ||
/// } | ||
/// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
Is it better to wait for #136 to be merged, rebase and then move the documentation to |
#136 modifies neither Also, please squash commits to one once you're ready 🙂 |
One last question, the doc test are now failing (since NodeVirtual and RefCountedVirtual don't exist yet) I hope this was helping and I have not been annoying with my slow pace and multiple questions ! |
Apart from that, I squashed it good it should be good to go 😉 |
Yep, agree, thanks a lot! This would also not need a rebase, bors automatically tests against latest |
#136 is now merged, this has some conflicts. @astrale-sharp could you rebase onto |
adds doc tests to godot-macros
Oh yea, I removed docs from bind.rs which was surpressed |
Seems to fail but I'm on my small laptop for weeks and it takes so long to compile godot-core x) |
No worries, the failures were a network issue, nothing caused by you. Thanks a lot for the documentation! |
Build succeeded: |
adds doc to godot::log::*
adds passing doc test for bind.rs
#35