Skip to content

Commit 72045c8

Browse files
anvilfolkHilderin
andcommitted
Scripting: Add script documentation cache to project
This PR adds a script documentation cache in the project folder. It is loaded at alongside native documentation caches. This makes scripts fully accessible through Search Help, including their members, etc, right from project start, without having to compile every single script. Co-authored-by: Hilderin <[email protected]>
1 parent 7490787 commit 72045c8

File tree

8 files changed

+358
-148
lines changed

8 files changed

+358
-148
lines changed

editor/doc_tools.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,15 @@ void DocTools::remove_doc(const String &p_class_name) {
368368
class_list.erase(p_class_name);
369369
}
370370

371+
void DocTools::remove_script_doc_by_path(const String &p_path) {
372+
for (KeyValue<String, DocData::ClassDoc> &E : class_list) {
373+
if (E.value.is_script_doc && E.value.script_path == p_path) {
374+
remove_doc(E.key);
375+
return;
376+
}
377+
}
378+
}
379+
371380
bool DocTools::has_doc(const String &p_class_name) {
372381
if (p_class_name.is_empty()) {
373382
return false;

editor/doc_tools.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class DocTools {
4444
void merge_from(const DocTools &p_data);
4545
void add_doc(const DocData::ClassDoc &p_class_doc);
4646
void remove_doc(const String &p_class_name);
47+
void remove_script_doc_by_path(const String &p_path);
4748
bool has_doc(const String &p_class_name);
4849
enum GenerateFlags {
4950
GENERATE_FLAG_SKIP_BASIC_TYPES = (1 << 0),

editor/editor_file_system.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,6 +2171,7 @@ void EditorFileSystem::_update_script_documentation() {
21712171

21722172
if (!efd || index < 0) {
21732173
// The file was removed
2174+
EditorHelp::remove_script_doc_by_path(path);
21742175
continue;
21752176
}
21762177

@@ -2188,7 +2189,7 @@ void EditorFileSystem::_update_script_documentation() {
21882189
scr->reload_from_file();
21892190
}
21902191
for (const DocData::ClassDoc &cd : scr->get_documentation()) {
2191-
EditorHelp::get_doc_data()->add_doc(cd);
2192+
EditorHelp::add_doc(cd);
21922193
if (!first_scan) {
21932194
// Update the documentation in the Script Editor if it is open.
21942195
ScriptEditor::get_singleton()->update_doc(cd.name);

0 commit comments

Comments
 (0)