summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-12-02 14:15:38 +0100
committerGitHub <noreply@github.com>2020-12-02 14:15:38 +0100
commitd1231be1c8f8f2c16fd1047adcd3c7f997a07c1f (patch)
treef7ceec96ce5251a3f7ed7ed33abcb163f29f0ad3 /editor/plugins
parent0019aa940e661fcc5e6b8f333ca291ba8726e6e4 (diff)
parent42bfa169960b59c5d9337e9f63862f5feae92d58 (diff)
Merge pull request #41095 from ThakeeNathees/GDScript-Documentation
GDScript(2.0) Documentation generation system
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/script_editor_plugin.cpp76
-rw-r--r--editor/plugins/script_editor_plugin.h1
2 files changed, 77 insertions, 0 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 6ee8193291..12790a6746 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1249,13 +1249,35 @@ void ScriptEditor::_menu_option(int p_option) {
RES resource = current->get_edited_resource();
Ref<TextFile> text_file = resource;
+ Ref<Script> script = resource;
+
if (text_file != nullptr) {
current->apply_code();
_save_text_file(text_file, text_file->get_path());
break;
}
+
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
+ EditorHelp::get_doc_data()->remove_doc(doc.name);
+ }
+ }
+ }
+
editor->save_resource(resource);
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ EditorHelp::get_doc_data()->add_doc(doc);
+ update_doc(doc.name);
+ }
+ }
+
} break;
case FILE_SAVE_AS: {
if (trim_trailing_whitespace_on_save) {
@@ -1274,6 +1296,8 @@ void ScriptEditor::_menu_option(int p_option) {
RES resource = current->get_edited_resource();
Ref<TextFile> text_file = resource;
+ Ref<Script> script = resource;
+
if (text_file != nullptr) {
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
@@ -1289,9 +1313,27 @@ void ScriptEditor::_menu_option(int p_option) {
break;
}
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
+ EditorHelp::get_doc_data()->remove_doc(doc.name);
+ }
+ }
+ }
+
editor->push_item(resource.ptr());
editor->save_resource_as(resource);
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ EditorHelp::get_doc_data()->add_doc(doc);
+ update_doc(doc.name);
+ }
+ }
} break;
case FILE_TOOL_RELOAD:
@@ -2318,11 +2360,33 @@ void ScriptEditor::save_all_scripts() {
if (edited_res->get_path() != "" && edited_res->get_path().find("local://") == -1 && edited_res->get_path().find("::") == -1) {
Ref<TextFile> text_file = edited_res;
+ Ref<Script> script = edited_res;
+
if (text_file != nullptr) {
_save_text_file(text_file, text_file->get_path());
continue;
}
+
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
+ EditorHelp::get_doc_data()->remove_doc(doc.name);
+ }
+ }
+ }
+
editor->save_resource(edited_res); //external script, save it
+
+ if (script != nullptr) {
+ const Vector<DocData::ClassDoc> &documentations = script->get_documentation();
+ for (int j = 0; j < documentations.size(); j++) {
+ const DocData::ClassDoc &doc = documentations.get(j);
+ EditorHelp::get_doc_data()->add_doc(doc);
+ update_doc(doc.name);
+ }
+ }
}
}
@@ -2900,6 +2964,18 @@ void ScriptEditor::_help_class_goto(const String &p_desc) {
_save_layout();
}
+void ScriptEditor::update_doc(const String &p_name) {
+ ERR_FAIL_COND(!EditorHelp::get_doc_data()->has_doc(p_name));
+
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
+ EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
+ if (eh && eh->get_class() == p_name) {
+ eh->update_doc();
+ return;
+ }
+ }
+}
+
void ScriptEditor::_update_selected_editor_menu() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
bool current = tab_container->get_current_tab() == i;
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index f1453c3d20..cc02a1ccbe 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -482,6 +482,7 @@ public:
void close_builtin_scripts_from_scene(const String &p_scene);
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
+ void update_doc(const String &p_name);
bool can_take_away_focus() const;