diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index a3e5d775f1a..c790de5bbd8 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -368,6 +368,15 @@ void DocTools::remove_doc(const String &p_class_name) { class_list.erase(p_class_name); } +void DocTools::remove_script_doc_by_path(const String &p_path) { + for (KeyValue &E : class_list) { + if (E.value.is_script_doc && E.value.script_path == p_path) { + remove_doc(E.key); + return; + } + } +} + bool DocTools::has_doc(const String &p_class_name) { if (p_class_name.is_empty()) { return false; diff --git a/editor/doc_tools.h b/editor/doc_tools.h index 6dd9d5ebcb1..fcac2c2142c 100644 --- a/editor/doc_tools.h +++ b/editor/doc_tools.h @@ -44,6 +44,7 @@ public: void merge_from(const DocTools &p_data); void add_doc(const DocData::ClassDoc &p_class_doc); void remove_doc(const String &p_class_name); + void remove_script_doc_by_path(const String &p_path); bool has_doc(const String &p_class_name); enum GenerateFlags { GENERATE_FLAG_SKIP_BASIC_TYPES = (1 << 0), diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 16a7578d8ac..0a4468dc9c5 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -2171,6 +2171,7 @@ void EditorFileSystem::_update_script_documentation() { if (!efd || index < 0) { // The file was removed + EditorHelp::remove_script_doc_by_path(path); continue; } @@ -2188,7 +2189,7 @@ void EditorFileSystem::_update_script_documentation() { scr->reload_from_file(); } for (const DocData::ClassDoc &cd : scr->get_documentation()) { - EditorHelp::get_doc_data()->add_doc(cd); + EditorHelp::add_doc(cd); if (!first_scan) { // Update the documentation in the Script Editor if it is open. ScriptEditor::get_singleton()->update_doc(cd.name); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 3a42405f625..bf6349ded52 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -40,6 +40,7 @@ #include "core/string/string_builder.h" #include "core/version_generated.gen.h" #include "editor/doc_data_compressed.gen.h" +#include "editor/editor_file_system.h" #include "editor/editor_main_screen.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" @@ -192,37 +193,6 @@ static String _contextualize_class_specifier(const String &p_class_specifier, co /// EditorHelp /// -// TODO: This is sometimes used directly as `doc->something`, other times as `EditorHelp::get_doc_data()`, which is thread-safe. -// Might this be a problem? -DocTools *EditorHelp::doc = nullptr; -DocTools *EditorHelp::ext_doc = nullptr; - -int EditorHelp::doc_generation_count = 0; -String EditorHelp::doc_version_hash; -Thread EditorHelp::worker_thread; - -static bool _attempt_doc_load(const String &p_class) { - // Docgen always happens in the outer-most class: it also generates docs for inner classes. - const String outer_class = p_class.get_slicec('.', 0); - if (!ScriptServer::is_global_class(outer_class)) { - return false; - } - - // `ResourceLoader` is used in order to have a script-agnostic way to load scripts. - // This forces GDScript to compile the code, which is unnecessary for docgen, but it's a good compromise right now. - const Ref