diff options
author | Thakee Nathees <thakeenathees@gmail.com> | 2020-11-29 09:12:06 +0530 |
---|---|---|
committer | Thakee Nathees <thakeenathees@gmail.com> | 2020-12-02 00:48:39 +0530 |
commit | 42bfa169960b59c5d9337e9f63862f5feae92d58 (patch) | |
tree | 5d20c798d3163bf6bbd80e5658278331d98c4ed2 /modules | |
parent | d0e7d9b62f0bcc2ba438b12c8bfbf68d82fff0ea (diff) |
Refactor DocData into core and editor (DocTools) parts
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdnative/nativescript/nativescript.h | 1 | ||||
-rw-r--r-- | modules/gdnative/pluginscript/pluginscript_script.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript.cpp | 20 | ||||
-rw-r--r-- | modules/gdscript/gdscript.h | 3 | ||||
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 6 | ||||
-rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 18 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 2 | ||||
-rw-r--r-- | modules/gdscript/language_server/gdscript_language_protocol.cpp | 3 | ||||
-rw-r--r-- | modules/gdscript/language_server/gdscript_workspace.cpp | 3 | ||||
-rw-r--r-- | modules/gdscript/language_server/lsp.hpp | 2 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 2 | ||||
-rw-r--r-- | modules/mono/csharp_script.h | 1 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 2 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.h | 3 | ||||
-rw-r--r-- | modules/visual_script/visual_script.h | 1 | ||||
-rw-r--r-- | modules/visual_script/visual_script_property_selector.cpp | 3 |
17 files changed, 32 insertions, 44 deletions
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index 7f736bdea7..e91d9b7bfb 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -31,6 +31,7 @@ #ifndef NATIVE_SCRIPT_H #define NATIVE_SCRIPT_H +#include "core/doc_data.h" #include "core/io/resource.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h index 790e4d5ffb..dc1ed6d576 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.h +++ b/modules/gdnative/pluginscript/pluginscript_script.h @@ -32,6 +32,8 @@ #define PLUGINSCRIPT_SCRIPT_H // Godot imports + +#include "core/doc_data.h" #include "core/object/script_language.h" // PluginScript imports #include "pluginscript_language.h" diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 8524ec276a..b00eb6f75b 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -39,8 +39,6 @@ #include "core/io/file_access_encrypted.h" #include "core/os/file_access.h" #include "core/os/os.h" -#include "editor/editor_help.h" -#include "editor/plugins/script_editor_plugin.h" #include "gdscript_analyzer.h" #include "gdscript_cache.h" #include "gdscript_compiler.h" @@ -242,7 +240,7 @@ void GDScript::_get_script_method_list(List<MethodInfo> *r_list, bool p_include_ mi.name = E->key(); for (int i = 0; i < func->get_argument_count(); i++) { PropertyInfo arginfo = func->get_argument_type(i); -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED arginfo.name = func->get_argument_name(i); #endif mi.arguments.push_back(arginfo); @@ -419,11 +417,8 @@ void GDScript::_add_doc(const DocData::ClassDoc &p_inner_class) { } void GDScript::_clear_doc() { - if (EditorHelp::get_doc_data() && EditorHelp::get_doc_data()->has_doc(doc.name)) { - EditorHelp::get_doc_data()->remove_doc(doc.name); - doc = DocData::ClassDoc(); - } docs.clear(); + doc = DocData::ClassDoc(); } void GDScript::_update_doc() { @@ -581,13 +576,6 @@ void GDScript::_update_doc() { E->get()->_update_doc(); } - if (EditorHelp::get_doc_data()) { - EditorHelp::get_doc_data()->add_doc(doc); - } - if (ScriptEditor::get_singleton()) { - ScriptEditor::get_singleton()->update_doc(doc.name); - } - _add_doc(doc); } #endif @@ -845,8 +833,8 @@ Error GDScript::reload(bool p_keep_state) { GDScriptCompiler compiler; err = compiler.compile(&parser, this, p_keep_state); -#if TOOLS_ENABLED - this->_update_doc(); +#ifdef TOOLS_ENABLED + _update_doc(); #endif if (err) { diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index a7052914ba..3eb260f95f 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -33,10 +33,10 @@ #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" +#include "core/doc_data.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/object/script_language.h" -#include "editor/doc_data.h" #include "gdscript_function.h" class GDScriptNativeClass : public Reference { @@ -470,6 +470,7 @@ public: virtual Script *create_script() const; virtual bool has_named_classes() const; virtual bool supports_builtin_mode() const; + virtual bool supports_documentation() const; virtual bool can_inherit_from_file() { return true; } virtual int find_function(const String &p_function, const String &p_code) const; virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const; diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 3de09eec05..97f10d4013 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -2009,7 +2009,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar } } -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED p_script->doc_functions.clear(); p_script->doc_variables.clear(); p_script->doc_constants.clear(); @@ -2142,7 +2142,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar } else { prop_info.usage = PROPERTY_USAGE_SCRIPT_VARIABLE; } -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED p_script->doc_variables[name] = variable->doc_description; #endif @@ -2224,7 +2224,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar parameters_names.write[j] = signal->parameters[j]->identifier->name; } p_script->_signals[name] = parameters_names; -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED if (!signal->doc_description.empty()) { p_script->doc_signals[name] = signal->doc_description; } diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index a426046797..4f847923a4 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -193,6 +193,10 @@ bool GDScriptLanguage::supports_builtin_mode() const { return true; } +bool GDScriptLanguage::supports_documentation() const { + return true; +} + int GDScriptLanguage::find_function(const String &p_function, const String &p_code) const { GDScriptTokenizer tokenizer; tokenizer.set_source_code(p_code); diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 5259e831e9..48fca16ab1 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -561,11 +561,7 @@ void GDScriptParser::parse_program() { #ifdef TOOLS_ENABLED for (Map<int, GDScriptTokenizer::CommentData>::Element *E = tokenizer.get_comments().front(); E; E = E->next()) { if (E->get().new_line && E->get().comment.begins_with("##")) { - if (class_doc_line == -1) { - class_doc_line = E->key(); - } else { - class_doc_line = MIN(class_doc_line, E->key()); - } + class_doc_line = MIN(class_doc_line, E->key()); } } if (has_comment(class_doc_line)) { @@ -708,6 +704,7 @@ void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)() #ifdef TOOLS_ENABLED // Consume doc comments. + class_doc_line = MIN(class_doc_line, doc_comment_line - 1); if (has_comment(doc_comment_line)) { if constexpr (std::is_same_v<T, ClassNode>) { get_class_doc_comment(doc_comment_line, member->doc_brief_description, member->doc_description, member->doc_tutorials, true); @@ -2741,12 +2738,6 @@ String GDScriptParser::get_doc_comment(int p_line, bool p_single_line) { line--; } - if (class_doc_line == -1) { - class_doc_line = line - 1; - } else { - class_doc_line = MIN(class_doc_line, line) - 1; - } - int codeblock_begins = 0; while (comments.has(line)) { if (!comments[line].new_line || !comments[line].comment.begins_with("##")) { @@ -2800,11 +2791,6 @@ void GDScriptParser::get_class_doc_comment(int p_line, String &p_brief, String & } line--; } - if (class_doc_line == -1) { - class_doc_line = line - 1; - } else { - class_doc_line = MIN(class_doc_line, line) - 1; - } } int codeblock_begins = 0; diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 598ac9cd34..44605bc20f 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1303,7 +1303,7 @@ private: TypeNode *parse_type(bool p_allow_void = false); #ifdef TOOLS_ENABLED // Doc comments. - int class_doc_line = -1; + int class_doc_line = 0x7FFFFFFF; bool has_comment(int p_line); String get_doc_comment(int p_line, bool p_single_line = false); void get_class_doc_comment(int p_line, String &p_brief, String &p_desc, Vector<Pair<String, String>> &p_tutorials, bool p_inner_class); diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 6ddb0d149e..729be237ec 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -33,6 +33,7 @@ #include "core/config/project_settings.h" #include "core/io/json.h" #include "core/os/copymem.h" +#include "editor/doc_tools.h" #include "editor/editor_log.h" #include "editor/editor_node.h" @@ -212,7 +213,7 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { void GDScriptLanguageProtocol::initialized(const Variant &p_params) { lsp::GodotCapabilities capabilities; - DocData *doc = EditorHelp::get_doc_data(); + DocTools *doc = EditorHelp::get_doc_data(); for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) { lsp::GodotNativeClassInfo gdclass; gdclass.name = E->get().name; diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index f6643d07f9..60668e7b31 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -34,6 +34,7 @@ #include "../gdscript_parser.h" #include "core/config/project_settings.h" #include "core/object/script_language.h" +#include "editor/doc_tools.h" #include "editor/editor_file_system.h" #include "editor/editor_help.h" #include "editor/editor_node.h" @@ -189,7 +190,7 @@ Error GDScriptWorkspace::initialize() { return OK; } - DocData *doc = EditorHelp::get_doc_data(); + DocTools *doc = EditorHelp::get_doc_data(); for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) { const DocData::ClassDoc &class_data = E->value(); lsp::DocumentSymbol class_symbol; diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index 288fd41c87..1029c53bbf 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -31,9 +31,9 @@ #ifndef GODOT_LSP_H #define GODOT_LSP_H +#include "core/doc_data.h" #include "core/object/class_db.h" #include "core/templates/list.h" -#include "editor/doc_data.h" namespace lsp { diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index b4537f531d..63ac0956f4 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2984,7 +2984,7 @@ void CSharpScript::update_script_class_info(Ref<CSharpScript> p_script) { p_script->tool = nesting_class && nesting_class->has_attribute(CACHED_CLASS(ToolAttribute)); } -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED if (!p_script->tool) { p_script->tool = p_script->script_class->get_assembly() == GDMono::get_singleton()->get_tools_assembly(); } diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 4c6e624b8a..f482cc21f0 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -31,6 +31,7 @@ #ifndef CSHARP_SCRIPT_H #define CSHARP_SCRIPT_H +#include "core/doc_data.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/object/script_language.h" diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index ff3122a77f..968f9f29c7 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -185,7 +185,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf return String(); } - DocData *doc = EditorHelp::get_doc_data(); + DocTools *doc = EditorHelp::get_doc_data(); String bbcode = p_bbcode; diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index eeab518954..6fefcd48a4 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -31,9 +31,10 @@ #ifndef BINDINGS_GENERATOR_H #define BINDINGS_GENERATOR_H +#include "core/doc_data.h" #include "core/object/class_db.h" #include "core/string/string_builder.h" -#include "editor/doc_data.h" +#include "editor/doc_tools.h" #include "editor/editor_help.h" #if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index b34f6df113..59bdfb2fc3 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -33,6 +33,7 @@ #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" +#include "core/doc_data.h" #include "core/object/script_language.h" #include "core/os/thread.h" diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 875270e74f..54d86d5a9c 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -31,6 +31,7 @@ #include "visual_script_property_selector.h" #include "core/os/keyboard.h" +#include "editor/doc_tools.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "modules/visual_script/visual_script.h" @@ -437,7 +438,7 @@ void VisualScriptPropertySelector::_item_selected() { class_type = base_type; } - DocData *dd = EditorHelp::get_doc_data(); + DocTools *dd = EditorHelp::get_doc_data(); String text; String at_class = class_type; |