@@ -1024,6 +1024,10 @@ Error CSharpLanguage::open_in_external_editor(const Ref<Script> &p_script, int p
1024
1024
bool CSharpLanguage::overrides_external_editor () {
1025
1025
return get_godotsharp_editor ()->call (" OverridesExternalEditor" );
1026
1026
}
1027
+
1028
+ bool CSharpLanguage::supports_documentation () const {
1029
+ return true ;
1030
+ }
1027
1031
#endif
1028
1032
1029
1033
bool CSharpLanguage::debug_break_parse (const String &p_file, int p_line, const String &p_error) {
@@ -2100,6 +2104,56 @@ void GD_CLR_STDCALL CSharpScript::_add_property_default_values_callback(CSharpSc
2100
2104
p_script->exported_members_defval_cache [name] = value;
2101
2105
}
2102
2106
}
2107
+
2108
+ void CSharpScript::get_docs (Ref<CSharpScript> p_script) {
2109
+ Dictionary class_doc_dict;
2110
+ class_doc_dict.~Dictionary ();
2111
+
2112
+ GDMonoCache::managed_callbacks.ScriptManagerBridge_GetDocs (p_script.ptr (), &class_doc_dict);
2113
+
2114
+ p_script->docs .clear ();
2115
+
2116
+ if (class_doc_dict.is_empty ()) {
2117
+ // Script has no docs.
2118
+ return ;
2119
+ }
2120
+
2121
+ String inherits;
2122
+ Ref<CSharpScript> base = p_script->get_base_script ();
2123
+ if (base.is_null ()) {
2124
+ // Must be a native base type.
2125
+ inherits = p_script->get_instance_base_type ();
2126
+ } else {
2127
+ inherits = base->get_global_name ();
2128
+ if (inherits == StringName ()) {
2129
+ inherits = base->get_path ();
2130
+ }
2131
+ }
2132
+
2133
+ DocData::ClassDoc class_doc = DocData::ClassDoc ();
2134
+ class_doc.inherits = inherits;
2135
+ class_doc.name = class_doc_dict[" name" ];
2136
+ class_doc.brief_description = class_doc_dict[" description" ];
2137
+ class_doc.is_script_doc = true ;
2138
+
2139
+ Array property_docs_dict = class_doc_dict[" properties" ];
2140
+ for (Dictionary property_doc_dict : property_docs_dict) {
2141
+ DocData::PropertyDoc prop_doc;
2142
+ prop_doc.name = property_doc_dict[" name" ];
2143
+ prop_doc.description = property_doc_dict[" description" ];
2144
+ class_doc.properties .push_back (prop_doc);
2145
+ }
2146
+
2147
+ Array signals_docs_dict = class_doc_dict[" signals" ];
2148
+ for (Dictionary signals_doc_dict : signals_docs_dict) {
2149
+ DocData::MethodDoc signal_doc;
2150
+ signal_doc.name = signals_doc_dict[" name" ];
2151
+ signal_doc.description = signals_doc_dict[" description" ];
2152
+ class_doc.signals .push_back (signal_doc);
2153
+ }
2154
+
2155
+ p_script->docs .append (class_doc);
2156
+ }
2103
2157
#endif
2104
2158
2105
2159
bool CSharpScript::_update_exports (PlaceHolderScriptInstance *p_instance_to_update) {
@@ -2120,7 +2174,11 @@ bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_upda
2120
2174
#endif
2121
2175
{
2122
2176
#ifdef TOOLS_ENABLED
2123
- exports_invalidated = false ;
2177
+ if (!get_path ().is_empty ()) {
2178
+ // If the script doesn't have a path we can't properly add the CATEGORY PropertyInfo,
2179
+ // so we keep the exports invalidated so the next update can fix them.
2180
+ exports_invalidated = false ;
2181
+ }
2124
2182
#endif
2125
2183
2126
2184
changed = true ;
@@ -2223,6 +2281,15 @@ void CSharpScript::reload_registered_script(Ref<CSharpScript> p_script) {
2223
2281
p_script->_update_exports ();
2224
2282
2225
2283
#ifdef TOOLS_ENABLED
2284
+ get_docs (p_script);
2285
+ Vector<DocData::ClassDoc> docs = p_script->docs ;
2286
+ // At this point, `EditorFileSystem::_update_script_documentation()` cannot be triggered.
2287
+ if (EditorHelp::get_doc_data ()) {
2288
+ for (int i = 0 ; i < docs.size (); i++) {
2289
+ EditorHelp::get_doc_data ()->add_doc (docs[i]);
2290
+ }
2291
+ }
2292
+
2226
2293
// If the EditorFileSystem singleton is available, update the file;
2227
2294
// otherwise, the file will be updated when the singleton becomes available.
2228
2295
EditorFileSystem *efs = EditorFileSystem::get_singleton ();
@@ -2603,6 +2670,8 @@ Error CSharpScript::reload(bool p_keep_state) {
2603
2670
_update_exports ();
2604
2671
2605
2672
#ifdef TOOLS_ENABLED
2673
+ get_docs (this );
2674
+
2606
2675
// If the EditorFileSystem singleton is available, update the file;
2607
2676
// otherwise, the file will be updated when the singleton becomes available.
2608
2677
EditorFileSystem *efs = EditorFileSystem::get_singleton ();
0 commit comments