godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.34k stars 21.06k forks source link

The documentation for a class defined by the keyword 'class_name' does not appear when searching using the '(doc) Search Help' #86577

Open adrbodev opened 9 months ago

adrbodev commented 9 months ago

Tested versions

Reproducible in : 4.2.stable

System information

Godot v4.2.stable - Ubuntu 22.04.3 LTS 22.04 - X11 - Vulkan (Forward+) - dedicated Quadro M2000M (nvidia; 535.129.03) - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (8 Threads)

Issue description

The documentation for a class defined by the keyword 'class_name' does not appear when searching using the 'Search Help (doc)' bar located in the Workspace Script in the top-right corner of the script editor.

This documentation appears in the search bar the first time the file is loaded or the first time Godot is opened after modifying the file. Subsequent times, the class documentation is no longer suggested in the search bar.

Steps to reproduce

If you use the MRP (Minimal reproduction project), open the project and jump to the step 3.

1) Download the following repository : git clone https://gitlab.com/Tomateauketchup/la-state-makina.git /tmp/la-state-makina

2) Create a new empty project with Godot as follows:

Set Version Control metadata to None.

(ignore the warnings saying that the directory is not empty)

3) Ignore the four errors associated with the following files:

4) Do not exit the Godot editor. Click on "Script" in the Workspace. In the top-right corner of the script editor, click on "Search Help," and enter "SMStateMachine."

You should be able to open the SMStateMachine documentation, which should display correctly.

4 bis) (Optional) In the Godot editor, close all documentation, and scripts.

5) Quit the godot IDE.

6) Reopen the godot IDE.

If you didn't made the 4bis) operation, you should obtain the error : "No loader found for resource: res://addons/la-state-makina/src/state_machine/sm_state_machine.gd (expected type: SMStateMachine)" If you made the 4 bis) operation, you have no error.

7) Click on "Script" in the Workspace. In the top-right corner of the script editor, click on "Search Help," and enter "SMStateMachine."

The search toolbar should not suggest SMStateMachine.

This is a bug because we don't change anything in our project and the editor was able to display previously the documentation !

8) Quit the godot IDE.

9) Modify the source code with an external IDE (like vim) : /tmp/la-state-makina/addons/la-state-makina/src/state_machine/sm_state_machine.gd Add an empty line at the end of the file.

10) Reopen the godot IDE

11) Click on "Script" in the Workspace. In the top-right corner of the script editor, click on "Search Help," and enter "SMStateMachine."

Now, the search toolbar should suggest SMStateMachine, and you should be able to open the SMStateMachine documentation, which should display correctly.

11bis) (optional) In the Godot editor, close all scenes, documentation, and scripts.

12) Quit the godot IDE.

13) Reopen the godot IDE

If you didn't made the 11bis) operation, you should obtain the error : "No loader found for resource: res://addons/la-state-makina/src/state_machine/sm_state_machine.gd (expected type: SMStateMachine)" If you made the 11bis) operation, you have no error.

14) Click on "Script" in the Workspace. In the top-right corner of the script editor, click on "Search Help," and enter "SMStateMachine."

The search toolbar should no longer suggest SMStateMachine.

This is a bug, the editor was able to display previously the documentation.

Minimal reproduction project (MRP)

la-state-makina.zip

dalexeev commented 9 months ago

Probably a duplicate of:

nagidev commented 6 months ago

Facing the same issue. One workaround I found was to define class_name YouClass after the first documentation comment. Example:

extends Control
## A node for doing some stuff
class_name BetterControl
anvilfolk commented 1 month ago

I tested @nagidev's workaround on master and it did not work for me, so it was likely something else that happened to recompile the script in the background that time. Tested the MRP as per OP and it does appear to be a duplicate of #72406 as pointed out by @dalexeev. It is looking like it will be fixed by #95821.

Recommend closing this as a duplicate and reopening later if found to behave different due to classes being in an addon.