diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index a35d5b87e24..e209e971b8a 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -253,7 +253,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p } r_symbol.detail = "class " + r_symbol.name; { - String doc = p_class->doc_data.description; + String doc = p_class->doc_data.brief; if (!p_class->doc_data.description.is_empty()) { doc += "\n\n" + p_class->doc_data.description; } diff --git a/modules/gdscript/tests/scripts/lsp/doc_comments.gd b/modules/gdscript/tests/scripts/lsp/doc_comments.gd new file mode 100644 index 00000000000..c6d6303810b --- /dev/null +++ b/modules/gdscript/tests/scripts/lsp/doc_comments.gd @@ -0,0 +1,7 @@ +## brief +## +## description +## +## @tutorial(t1): https://example.com/t2 +## @tutorial: https://example.com/t3 +extends Node diff --git a/modules/gdscript/tests/test_lsp.h b/modules/gdscript/tests/test_lsp.h index 288eb71e5b9..ec9e59dc49b 100644 --- a/modules/gdscript/tests/test_lsp.h +++ b/modules/gdscript/tests/test_lsp.h @@ -509,6 +509,20 @@ func f(): } } + SUBCASE("Documentation is correctly set") { + String path = "res://lsp/doc_comments.gd"; + assert_no_errors_in(path); + GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_local_script(path); + ExtendGDScriptParser *parser = GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_results[path]; + REQUIRE(parser); + LSP::DocumentSymbol cls = parser->get_symbols(); + REQUIRE(cls.documentation.contains("brief")); + REQUIRE(cls.documentation.contains("description")); + REQUIRE(cls.documentation.contains("t1")); + REQUIRE(cls.documentation.contains("t2")); + REQUIRE(cls.documentation.contains("t3")); + } + memdelete(proto); finish_language(); }