-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Expose goto_help
for GDExtension on ScriptEditor
#90189
Conversation
I'd suggest exposing it in |
goto_help
for GDExtension toolinggoto_help
for GDExtension on ScriptEditor
Hi @AThousandShips, do you think there is any way this can be included in 4.3, given its simplicity? |
It depends, the 4.x is simply because all new features are assigned to 4.x until they're decided on, we haven't hit feature freeze yet, and this is small, so if it gets approved relatively soon it could be included in 4.3, but the fact that it's marked 4.x doesn't mean it can't possibly end up in 4.3 :) |
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.
Seems good to me!
The only potential roadblock is if the editor folks don't want to expose this method for some reason, but to me it seems like it'd be useful for both GDExtension and GDScript.
doc/classes/ScriptEditor.xml
Outdated
<return type="void" /> | ||
<param index="0" name="topic" type="String" /> | ||
<description> | ||
Opens help for the given topic. |
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 would be good to add details on what the topic is meant to be, with some examples.
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.
Hi @akien-mga, that's reasonable. Just one question, I was considering appending this:
For example: [code]class_name:<class_name>[/code] or [code]class_method:<class_name>:<method_name>[/code].
My concern in this context are the <
and >
and how they should be represented. I also tried to find some other examples in the repository and it wasn't immediately obvious of any I could use as a basis for how best to represent this type of example where there is expected tokens combined with variable user-supplied data. If there is, could you point me to a 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.
So the closest I found was in EditorCommandPalette
that uses:
[code]"example/command1"[/code] then [code]example[/code] will be the section name.
If that's acceptable here in this context, I could use "class"
and "method"
to represent the user-supplied values to distinguish it from the expected static values that the help system expects. wdyt?
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.
Updated, let me know if it needs any further adjustments.
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.
That looks ok, but there seems to be more types of topics supported by this method, see:
Lines 2246 to 2306 in 7e4c150
void EditorHelp::_help_callback(const String &p_topic) { | |
String what = p_topic.get_slice(":", 0); | |
String clss = p_topic.get_slice(":", 1); | |
String name; | |
if (p_topic.get_slice_count(":") == 3) { | |
name = p_topic.get_slice(":", 2); | |
} | |
_request_help(clss); // First go to class. | |
int line = 0; | |
if (what == "class_desc") { | |
line = description_line; | |
} else if (what == "class_signal") { | |
if (signal_line.has(name)) { | |
line = signal_line[name]; | |
} | |
} else if (what == "class_method" || what == "class_method_desc") { | |
if (method_line.has(name)) { | |
line = method_line[name]; | |
} | |
} else if (what == "class_property") { | |
if (property_line.has(name)) { | |
line = property_line[name]; | |
} | |
} else if (what == "class_enum") { | |
if (enum_line.has(name)) { | |
line = enum_line[name]; | |
} | |
} else if (what == "class_theme_item") { | |
if (theme_property_line.has(name)) { | |
line = theme_property_line[name]; | |
} | |
} else if (what == "class_constant") { | |
if (constant_line.has(name)) { | |
line = constant_line[name]; | |
} | |
} else if (what == "class_annotation") { | |
if (annotation_line.has(name)) { | |
line = annotation_line[name]; | |
} | |
} else if (what == "class_global") { | |
if (constant_line.has(name)) { | |
line = constant_line[name]; | |
} else if (method_line.has(name)) { | |
line = method_line[name]; | |
} else { | |
HashMap<String, HashMap<String, int>>::Iterator iter = enum_values_line.begin(); | |
while (true) { | |
if (iter->value.has(name)) { | |
line = iter->value[name]; | |
break; | |
} else if (iter == enum_values_line.last()) { | |
break; | |
} else { | |
++iter; | |
} | |
} | |
} | |
} |
So it should likely be a list or supported tags with their expected arguments.
And then a few real life examples like class_method:Node:add_child
.
Would also be good to figure out what's the format used for GDScript class docs so that this could be shown as an example too (maybe it's just the registered class_name
, I didn't check).
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.
So this is what I have come up with @AThousandShips / @akien-mga. It's a bit wordy, so I'm certainly open to suggestions, but I believe it conveys the details you requested.
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.
That looks really good!
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.
Looks great to me!
Thanks! And congrats for your first merged Godot contribution 🎉 |
Thanks 🎉 |
Exposes a helper method
goto_help
on theScriptEditor
that enables GDExtension and other tooling to request help to be displayed for a given help encoded descriptor string.