@@ -63,13 +63,13 @@ static String format_doc_text(const String &p_bbcode, const String &p_indent = "
6363 if (block_start != -1 ) {
6464 code_block_indent = block_start;
6565 in_code_block = true ;
66- line = " \n " ;
66+ line = " ```gdscript " ;
6767 } else if (in_code_block) {
68- line = " \t " + line.substr (code_block_indent, line.length ());
68+ line = line.substr (code_block_indent, line.length ());
6969 }
7070
7171 if (in_code_block && line.find (" [/codeblock]" ) != -1 ) {
72- line = " \n " ;
72+ line = " ``` " ;
7373 in_code_block = false ;
7474 }
7575
@@ -369,6 +369,10 @@ void ECMAScriptPlugin::_export_typescript_declare_file(const String &p_path) {
369369#endif
370370
371371 String classes = " " ;
372+ String constants = " " ;
373+ String enumerations_str = " " ;
374+ String functions = " " ;
375+
372376 for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list .front (); E; E = E->next ()) {
373377 DocData::ClassDoc class_doc = E->get ();
374378 if (ignored_classes.has (class_doc.name )) {
@@ -378,7 +382,6 @@ void ECMAScriptPlugin::_export_typescript_declare_file(const String &p_path) {
378382 if (class_doc.name .begins_with (" @" )) {
379383 HashMap<String, Vector<const DocData::ConstantDoc *> > enumerations;
380384 if (class_doc.name == " @GlobalScope" || class_doc.name == " @GDScript" ) {
381- String constants = " " ;
382385 String const_str = " \n "
383386 " \t /** ${description} */\n "
384387 " \t const ${name}: ${value};\n " ;
@@ -388,6 +391,9 @@ void ECMAScriptPlugin::_export_typescript_declare_file(const String &p_path) {
388391 dict[" description" ] = format_doc_text (const_doc.description , " \t " );
389392 dict[" name" ] = format_property_name (const_doc.name );
390393 dict[" value" ] = const_doc.value ;
394+ if (const_doc.value == " nan" || const_doc.value == " inf" ) {
395+ dict[" value" ] = " number" ;
396+ }
391397 constants += applay_partern (const_str, dict);
392398
393399 if (!const_doc.enumeration .empty ()) {
@@ -401,31 +407,6 @@ void ECMAScriptPlugin::_export_typescript_declare_file(const String &p_path) {
401407 }
402408 }
403409
404- GlobalNumberConstant consts[] = {
405- { " PI" , Math_PI },
406- { " TAU" , Math_TAU },
407- { " NAN" , Math_NAN },
408- { " INF" , Math_INF },
409- { " E" , Math_E },
410- { " LN2" , Math_LN2 },
411- { " SQRT2" , Math_SQRT2 },
412- { " SQRT12" , Math_SQRT12 },
413- };
414- for (int i = 0 ; i < sizeof (consts) / sizeof (GlobalNumberConstant); i++) {
415- Dictionary dict;
416- const GlobalNumberConstant &c = consts[i];
417- dict[" description" ] = format_doc_text (" " , " \t " );
418- dict[" name" ] = format_property_name (c.name );
419- dict[" value" ] = c.value ;
420- if (c.name == " NAN" || c.name == " INF" ) {
421- dict[" value" ] = " number" ;
422- }
423- constants += applay_partern (const_str, dict);
424- }
425-
426- dict[" constants" ] = constants;
427-
428- String enumerations_str = " " ;
429410 const String *enum_name = enumerations.next (NULL );
430411 while (enum_name) {
431412 String enum_str = " \t const " + (*enum_name).replace (" ." , " " ) + " : {\n " ;
@@ -443,9 +424,7 @@ void ECMAScriptPlugin::_export_typescript_declare_file(const String &p_path) {
443424 enumerations_str += enum_str;
444425 enum_name = enumerations.next (enum_name);
445426 }
446- dict[" enumerations" ] = enumerations_str;
447427
448- String functions = " " ;
449428 for (int i = 0 ; i < class_doc.methods .size (); i++) {
450429 const DocData::MethodDoc &method_doc = class_doc.methods [i];
451430 if (Expression::find_function (method_doc.name ) == Expression::FUNC_MAX) {
@@ -456,28 +435,15 @@ void ECMAScriptPlugin::_export_typescript_declare_file(const String &p_path) {
456435 }
457436 functions += _export_method (method_doc, true );
458437 }
459-
460- for (int i = 0 ; i < Expression::FUNC_MAX; i++) {
461- DocData::MethodDoc md;
462- md.name = Expression::get_func_name (Expression::BuiltinFunc (i));
463- md.return_type = " any" ;
464- if (md.name == " typeof" ) continue ;
465- for (int j = 0 ; j < Expression::get_func_argument_count (Expression::BuiltinFunc (i)); j++) {
466- DocData::ArgumentDoc ad;
467- ad.name = " v" + itos (j);
468- ad.type = " any" ;
469- md.arguments .push_back (ad);
470- }
471- functions += _export_method (md, true );
472- }
473-
474- dict[" functions" ] = functions;
475438 }
476439 continue ;
477440 }
478441 classes += _export_class (class_doc);
479442 }
480443 dict[" classes" ] = classes;
444+ dict[" constants" ] = constants;
445+ dict[" enumerations" ] = enumerations_str;
446+ dict[" functions" ] = functions;
481447 dict[" buitins" ] = BUILTIN_DECLEARATION_TEXT;
482448
483449 String text = applay_partern (godot_module, dict);
0 commit comments