|
31 | 31 | #include "editor_help.h" |
32 | 32 |
|
33 | 33 | #include "core/core_constants.h" |
| 34 | +#include "core/extension/gdextension.h" |
34 | 35 | #include "core/input/input.h" |
35 | 36 | #include "core/object/script_language.h" |
36 | 37 | #include "core/os/keyboard.h" |
@@ -83,6 +84,7 @@ const Vector<String> classes_with_csharp_differences = { |
83 | 84 | // TODO: this is sometimes used directly as doc->something, other times as EditorHelp::get_doc_data(), which is thread-safe. |
84 | 85 | // Might this be a problem? |
85 | 86 | DocTools *EditorHelp::doc = nullptr; |
| 87 | +DocTools *EditorHelp::ext_doc = nullptr; |
86 | 88 |
|
87 | 89 | static bool _attempt_doc_load(const String &p_class) { |
88 | 90 | // Docgen always happens in the outer-most class: it also generates docs for inner classes. |
@@ -2369,6 +2371,28 @@ String EditorHelp::get_cache_full_path() { |
2369 | 2371 | return EditorPaths::get_singleton()->get_cache_dir().path_join("editor_doc_cache.res"); |
2370 | 2372 | } |
2371 | 2373 |
|
| 2374 | +void EditorHelp::load_xml_buffer(const uint8_t *p_buffer, int p_size) { |
| 2375 | + if (!ext_doc) { |
| 2376 | + ext_doc = memnew(DocTools); |
| 2377 | + } |
| 2378 | + |
| 2379 | + ext_doc->load_xml(p_buffer, p_size); |
| 2380 | + |
| 2381 | + if (doc) { |
| 2382 | + doc->load_xml(p_buffer, p_size); |
| 2383 | + } |
| 2384 | +} |
| 2385 | + |
| 2386 | +void EditorHelp::remove_class(const String &p_class) { |
| 2387 | + if (ext_doc && ext_doc->has_doc(p_class)) { |
| 2388 | + ext_doc->remove_doc(p_class); |
| 2389 | + } |
| 2390 | + |
| 2391 | + if (doc && doc->has_doc(p_class)) { |
| 2392 | + doc->remove_doc(p_class); |
| 2393 | + } |
| 2394 | +} |
| 2395 | + |
2372 | 2396 | void EditorHelp::_load_doc_thread(void *p_udata) { |
2373 | 2397 | Ref<Resource> cache_res = ResourceLoader::load(get_cache_full_path()); |
2374 | 2398 | if (cache_res.is_valid() && cache_res->get_meta("version_hash", "") == doc_version_hash) { |
@@ -2416,6 +2440,11 @@ void EditorHelp::_gen_doc_thread(void *p_udata) { |
2416 | 2440 |
|
2417 | 2441 | void EditorHelp::_gen_extensions_docs() { |
2418 | 2442 | doc->generate((DocTools::GENERATE_FLAG_SKIP_BASIC_TYPES | DocTools::GENERATE_FLAG_EXTENSION_CLASSES_ONLY)); |
| 2443 | + |
| 2444 | + // Append extra doc data, as it gets overridden by the generation step. |
| 2445 | + if (ext_doc) { |
| 2446 | + doc->merge_from(*ext_doc); |
| 2447 | + } |
2419 | 2448 | } |
2420 | 2449 |
|
2421 | 2450 | void EditorHelp::generate_doc(bool p_use_cache) { |
@@ -2554,6 +2583,11 @@ void EditorHelp::_bind_methods() { |
2554 | 2583 | ADD_SIGNAL(MethodInfo("go_to_help")); |
2555 | 2584 | } |
2556 | 2585 |
|
| 2586 | +void EditorHelp::init_gdext_pointers() { |
| 2587 | + GDExtensionEditorHelp::editor_help_load_xml_buffer = &EditorHelp::load_xml_buffer; |
| 2588 | + GDExtensionEditorHelp::editor_help_remove_class = &EditorHelp::remove_class; |
| 2589 | +} |
| 2590 | + |
2557 | 2591 | EditorHelp::EditorHelp() { |
2558 | 2592 | set_custom_minimum_size(Size2(150 * EDSCALE, 0)); |
2559 | 2593 |
|
|
0 commit comments