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

C#: Implement tooltips for Signals and Properties in the inspector. #83505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

magian1127
Copy link
Contributor

@magian1127 magian1127 commented Oct 17, 2023

    /// <summary>
    /// tip text
    /// </summary>
    [Export]
    string s1 = "AAAA";

image
30N9OK8 7{39{)BWG@C(%RN
C D4LHV%8UP8 G)VKY_VUE

resolve godotengine/godot-proposals#8269

@geekley
Copy link

geekley commented Dec 30, 2023

Would it be possible to reuse this implementation for documentation of GDShader uniform fields? They are shown in the inspector, and it would be really useful for sharing shaders; e.g. on sites like https://godotshaders.com

@magian1127 magian1127 force-pushed the 4.0tip branch 2 times, most recently from 9c21641 to 943ddbc Compare January 4, 2024 07:24
@magian1127 magian1127 marked this pull request as draft March 24, 2024 06:18
@magian1127 magian1127 force-pushed the 4.0tip branch 3 times, most recently from 601893f to 4f4ee11 Compare March 24, 2024 07:58
@magian1127 magian1127 marked this pull request as ready for review March 24, 2024 07:59
@van800
Copy link
Contributor

van800 commented Mar 30, 2024

If this gets approved, it looks like worth setting
GenerateDocumentationFile in the Godot net sdk.

@mhilbrunner
Copy link
Member

mhilbrunner commented Apr 6, 2024

Removing the documentation label, as while this PR deals with documentation generation/display, this is more suited for the dotnet team to handle :)

@magian1127
Copy link
Contributor Author

Remove the need for GenerateDocumentationFile=true.

@magian1127
Copy link
Contributor Author

Hi @anvilfolk !
Sorry, I don't speak English very well, and real-time communication is difficult for me.
Currently, I am creating the PR based on the current GODOT code. After your PR is merged, I will make further modifications or submit a new PR.

@anvilfolk
Copy link
Contributor

No worries. I can also speak portuguese, french and some spanish if that is better. I am making progress on the other PR!

Hope to see C# documentation working soon! <3

Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

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

Thanks for your patience and continued work on this feature. This is already looking pretty good, so I'm moving it to the 4.4 milestone because it seems likely to be finished on time and we want to include it in the next stable release.

However, keep in mind this is not a guarantee that it will be in the 4.4 release, it may still be pushed to a future release if we run into issues.

Also, would you be able to add tests for the new generator in Godot.SourceGenerators.Tests? This will help ensure that future changes to the generator don't change the generated code in unexpected ways.

Comment on lines 1977 to 1987
bool should_reload_script = _should_reload_script(path);
Ref<Script> scr = ResourceLoader::load(path);
if (scr.is_null()) {
continue;
}
if (should_reload_script) {
// Reloading the script from disk. Otherwise, the ResourceLoader::load will
// return the last loaded version of the script (without the modifications).
scr->reload_from_file();
if (lang->get_name() != "C#") {
bool should_reload_script = _should_reload_script(path);
if (should_reload_script) {
// Reloading the script from disk. Otherwise, the ResourceLoader::load will
// return the last loaded version of the script (without the modifications).
scr->reload_from_file();
}
Copy link
Member

Choose a reason for hiding this comment

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

These changes don't seem to be needed, so I would revert them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Modify the code in VS.
  2. Rebuild in Godot.
  3. This will execute reload_from_file.
  4. Then, GodotSharp will throw an error about _scriptTypeBiMap being added multiple times.

Because of lang->supports_documentation(), C# will never execute here.
However, this PR adds supports_documentation().
If we don't include it, we'll need to modify _should_reload_script.

Copy link
Member

Choose a reason for hiding this comment

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

@magian1127 This still needs to be addressed. In my testing it didn't seem to be needed, but I could be missing something, so if you still think it's needed could you explain why? Thank you.

Copy link
Contributor

@anvilfolk anvilfolk Oct 4, 2024

Choose a reason for hiding this comment

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

Yeah, I'd hate to see code like this start getting added, especially if folks end up adding more scripting languages in the future.

We should eventually all get together and figure out what a good doc-generation architecture might be. It probably wants to live inside Script, ScriptLanguage and ScriptServer, which would abstract it away nicely and not require special cases!

Copy link
Member

Choose a reason for hiding this comment

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

@magian1127 Thanks, I'm able to reproduce the exception. I understand why you made this change now.

Reloading a C# script checks if the script is already registered before trying to register it again. So if it still throws after that, it must mean the script is different, and that's a bug. There must always be only one CSharpScript instance for each C# type, so if another one is being created somewhere we need to find where.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The potentially related PR #98269

@raulsntos raulsntos modified the milestones: 4.x, 4.4 Sep 28, 2024
Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

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

The latest changes look good, although there's still an unresolved comment. I added a few more comments, but it should be the last batch and then we can move on to a code-style review.

@magian1127
Copy link
Contributor Author

magian1127 commented Oct 5, 2024

@magian1127 This still needs to be addressed. In my testing it didn't seem to be needed, but I could be missing something, so if you still think it's needed could you explain why? Thank you.

image
@raulsntos
I have written the cause and steps to reproduce. After rebuilding the project, scr->reload_from_file() causes the script to be registered multiple times.

@raulsntos
Copy link
Member

It seems you forgot to submit the message. Notice the 待定1 next to your account name.

Footnotes

  1. I think that's what it says, but I can't speak Chinese. I believe this is Pending in English and it appears on messages added in a review that hasn't been submitted yet.

@magian1127
Copy link
Contributor Author

😓 Some comments have not been replied to because the 'Review changes' button in the upper right corner was not clicked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for generating class reference descriptions from C# documentation comments