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

Expose goto_help for GDExtension on ScriptEditor #90189

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

Naros
Copy link
Contributor

@Naros Naros commented Apr 4, 2024

Exposes a helper method goto_help on the ScriptEditor that enables GDExtension and other tooling to request help to be displayed for a given help encoded descriptor string.

@AThousandShips
Copy link
Member

I'd suggest exposing it in ScriptEditor instead as you can access that

@Naros Naros force-pushed the expose-goto-help branch from 41349cb to 9dc6abc Compare April 4, 2024 11:41
@Naros Naros requested a review from a team as a code owner April 4, 2024 11:41
@Naros Naros changed the title Expose goto_help for GDExtension tooling Expose goto_help for GDExtension on ScriptEditor Apr 4, 2024
@Naros
Copy link
Contributor Author

Naros commented Apr 4, 2024

Hi @AThousandShips, do you think there is any way this can be included in 4.3, given its simplicity?

@AThousandShips
Copy link
Member

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 :)

Copy link
Contributor

@dsnopek dsnopek left a 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.

@dsnopek dsnopek requested a review from a team April 4, 2024 18:31
<return type="void" />
<param index="0" name="topic" type="String" />
<description>
Opens help for the given topic.
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

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:

godot/editor/editor_help.cpp

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).

Copy link
Contributor Author

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.

image

Copy link
Member

Choose a reason for hiding this comment

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

That looks really good!

@Naros Naros force-pushed the expose-goto-help branch from 9dc6abc to 3b18adb Compare April 5, 2024 12:04
@Naros Naros force-pushed the expose-goto-help branch from 3b18adb to d8f1287 Compare April 16, 2024 23:32
Copy link
Member

@akien-mga akien-mga left a 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!

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Apr 17, 2024
@akien-mga akien-mga merged commit 84457f6 into godotengine:master Apr 17, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@Naros
Copy link
Contributor Author

Naros commented Apr 17, 2024

Thanks! And congrats for your first merged Godot contribution 🎉

Thanks 🎉

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.

4 participants