Accessing the class reference documentation via script

Godot Version

4.4 dev 2

Question

I want to access the class reference documentation for a specific class. Maybe something like this:

func get_documentation(class_name:String) -> String:
    # magically returns the documentation

I could try to get the documentation text node in the Godot editor itself, but that seems like a bit much work for getting some documentation.

func go_to_help(msg:String):
	if msg.contains("/"):
		msg='"'+msg.replace("res://","").replace('"',"").replace("'","")+'"'
	msg='class'+'_name:'+msg.replace('class'+'_name:',"")
	EditorInterface.get_script_editor().get_current_editor().go_to_help.emit(msg)

While this is useful, this is not quite what I needed.
I wanted to get the documentation of a class, not open it.

Then you can only choose from the following five options:

  1. Modify Godot, implementation method unknown
  2. Create GDExtension, the implementation method is unknown, but you can take a look at the source code of the orchestrator
  3. Analyze class documents by obtaining help nodes, then obtaining text, and finally parsing.
    Disadvantages: 1. Due to the absence of spaces in some areas, only a portion of the document can be obtained. 2. Manual parsing is required
  4. To parse class files, the implementation method is:load("C:/Users/shen/AppData/Local/Godot/editor_doc_cache.res")
    Disadvantages: 1. No translation, 2. This is a large array, you can open it yourself to see the details, 3. It needs to be manually parsed
  5. Give up
    Advantages: Fast and efficient

If you find a better implementation, please let me know

I might try the third method of searching for the correct node which has the text itself. I’m searching through the scene tree, and under Mainscreen, there are loads of different control Nodes. I have already looked through the first four and couldn’t find the correct Node yet (even with the help help open). This might take a bit longer…
grafik

It seems that you have chosen the same path as me. In fact, I have created a plugin to parse class documents and create help buttons.

Could you share a link to your plugin maybe? Or tell me specifically how you did it?

engine_script_editor = EditorInterface.get_script_editor()
engine_edit_tab=engine_script_editor.get_child(0).get_child(1).get_child(1).get_child(0)
for i in engine_edit_tab.get_children():
	if i.get_class()=="EditorHelp":
		var engine_edit_help:RichTextLabel=i.get_child(0)
        engine_edit_help.select_all()
		edit=engine_edit_help.get_selected_text()