/**************************************************************************/ /* editor_help.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "editor_help.h" #include "core/core_constants.h" #include "core/input/input.h" #include "core/object/script_language.h" #include "core/os/keyboard.h" #include "core/version.h" #include "doc_data_compressed.gen.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/plugins/script_editor_plugin.h" #include "scene/gui/line_edit.h" #define CONTRIBUTE_URL vformat("%s/contributing/documentation/updating_the_class_reference.html", VERSION_DOCS_URL) #ifdef MODULE_MONO_ENABLED // Sync with the types mentioned in https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_differences.html const Vector classes_with_csharp_differences = { "@GlobalScope", "String", "NodePath", "Signal", "Callable", "RID", "Basis", "Transform2D", "Transform3D", "Rect2", "Rect2i", "AABB", "Quaternion", "Projection", "Color", "Array", "Dictionary", "PackedByteArray", "PackedColorArray", "PackedFloat32Array", "PackedFloat64Array", "PackedInt32Array", "PackedInt64Array", "PackedStringArray", "PackedVector2Array", "PackedVector3Array", "Variant", }; #endif // 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; class DocCache : public Resource { GDCLASS(DocCache, Resource); RES_BASE_EXTENSION("doc_cache"); String version_hash; Array classes; protected: static void _bind_methods() { ClassDB::bind_method(D_METHOD("set_version_hash", "version_hash"), &DocCache::set_version_hash); ClassDB::bind_method(D_METHOD("get_version_hash"), &DocCache::get_version_hash); ClassDB::bind_method(D_METHOD("set_classes", "classes"), &DocCache::set_classes); ClassDB::bind_method(D_METHOD("get_classes"), &DocCache::get_classes); ADD_PROPERTY(PropertyInfo(Variant::STRING, "version_hash"), "set_version_hash", "get_version_hash"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "classes"), "set_classes", "get_classes"); } public: String get_version_hash() const { return version_hash; } void set_version_hash(const String &p_version_hash) { version_hash = p_version_hash; } Array get_classes() const { return classes; } void set_classes(const Array &p_classes) { classes = p_classes; } }; static bool _attempt_doc_load(const String &p_class) { // Docgen always happens in the outer-most class: it also generates docs for inner classes. String outer_class = p_class.get_slice(".", 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. Ref