@@ -637,6 +637,7 @@ void Main::print_help(const char *p_binary) {
637
637
#endif // DISABLE_DEPRECATED
638
638
print_help_option (" --doctool [path]" , " Dump the engine API reference to the given <path> (defaults to current directory) in XML format, merging if existing files are found.\n " , CLI_OPTION_AVAILABILITY_EDITOR);
639
639
print_help_option (" --no-docbase" , " Disallow dumping the base types (used with --doctool).\n " , CLI_OPTION_AVAILABILITY_EDITOR);
640
+ print_help_option (" --gdextension-docs" , " Rather than dumping the engine API, generate API reference from all the GDExtensions loaded in the current project (used with --doctool).\n " , CLI_OPTION_AVAILABILITY_EDITOR);
640
641
#ifdef MODULE_GDSCRIPT_ENABLED
641
642
print_help_option (" --gdscript-docs <path>" , " Rather than dumping the engine API, generate API reference from the inline documentation in the GDScript files found in <path> (used with --doctool).\n " , CLI_OPTION_AVAILABILITY_EDITOR);
642
643
#endif
@@ -3214,6 +3215,9 @@ int Main::start() {
3214
3215
#ifdef TOOLS_ENABLED
3215
3216
} else if (E->get () == " --no-docbase" ) {
3216
3217
gen_flags.set_flag (DocTools::GENERATE_FLAG_SKIP_BASIC_TYPES);
3218
+ } else if (E->get () == " --gdextension-docs" ) {
3219
+ gen_flags.set_flag (DocTools::GENERATE_FLAG_SKIP_BASIC_TYPES);
3220
+ gen_flags.set_flag (DocTools::GENERATE_FLAG_EXTENSION_CLASSES_ONLY);
3217
3221
#ifndef DISABLE_DEPRECATED
3218
3222
} else if (E->get () == " --convert-3to4" ) {
3219
3223
converting_project = true ;
@@ -3340,29 +3344,34 @@ int Main::start() {
3340
3344
HashSet<String> checked_paths;
3341
3345
print_line (" Loading docs..." );
3342
3346
3343
- for (int i = 0 ; i < _doc_data_class_path_count; i++) {
3344
- // Custom modules are always located by absolute path.
3345
- String path = _doc_data_class_paths[i].path ;
3346
- if (path.is_relative_path ()) {
3347
- path = doc_tool_path.path_join (path);
3348
- }
3349
- String name = _doc_data_class_paths[i].name ;
3350
- doc_data_classes[name] = path;
3351
- if (!checked_paths.has (path)) {
3352
- checked_paths.insert (path);
3353
-
3354
- // Create the module documentation directory if it doesn't exist
3355
- Ref<DirAccess> da = DirAccess::create_for_path (path);
3356
- err = da->make_dir_recursive (path);
3357
- ERR_FAIL_COND_V_MSG (err != OK, EXIT_FAILURE, " Error: Can't create directory: " + path + " : " + itos (err));
3358
-
3359
- print_line (" Loading docs from: " + path);
3360
- err = docsrc.load_classes (path);
3361
- ERR_FAIL_COND_V_MSG (err != OK, EXIT_FAILURE, " Error loading docs from: " + path + " : " + itos (err));
3347
+ const bool gdextension_docs = gen_flags.has_flag (DocTools::GENERATE_FLAG_EXTENSION_CLASSES_ONLY);
3348
+
3349
+ if (!gdextension_docs) {
3350
+ for (int i = 0 ; i < _doc_data_class_path_count; i++) {
3351
+ // Custom modules are always located by absolute path.
3352
+ String path = _doc_data_class_paths[i].path ;
3353
+ if (path.is_relative_path ()) {
3354
+ path = doc_tool_path.path_join (path);
3355
+ }
3356
+ String name = _doc_data_class_paths[i].name ;
3357
+ doc_data_classes[name] = path;
3358
+ if (!checked_paths.has (path)) {
3359
+ checked_paths.insert (path);
3360
+
3361
+ // Create the module documentation directory if it doesn't exist
3362
+ Ref<DirAccess> da = DirAccess::create_for_path (path);
3363
+ err = da->make_dir_recursive (path);
3364
+ ERR_FAIL_COND_V_MSG (err != OK, EXIT_FAILURE, " Error: Can't create directory: " + path + " : " + itos (err));
3365
+
3366
+ print_line (" Loading docs from: " + path);
3367
+ err = docsrc.load_classes (path);
3368
+ ERR_FAIL_COND_V_MSG (err != OK, EXIT_FAILURE, " Error loading docs from: " + path + " : " + itos (err));
3369
+ }
3362
3370
}
3363
3371
}
3364
3372
3365
- String index_path = doc_tool_path.path_join (" doc/classes" );
3373
+ // For GDExtension docs, use a path that is compatible with Godot modules.
3374
+ String index_path = gdextension_docs ? doc_tool_path.path_join (" doc_classes" ) : doc_tool_path.path_join (" doc/classes" );
3366
3375
// Create the main documentation directory if it doesn't exist
3367
3376
Ref<DirAccess> da = DirAccess::create_for_path (index_path);
3368
3377
err = da->make_dir_recursive (index_path);
@@ -3383,7 +3392,7 @@ int Main::start() {
3383
3392
}
3384
3393
3385
3394
print_line (" Generating new docs..." );
3386
- err = doc.save_classes (index_path, doc_data_classes);
3395
+ err = doc.save_classes (index_path, doc_data_classes, !gdextension_docs );
3387
3396
ERR_FAIL_COND_V_MSG (err != OK, EXIT_FAILURE, " Error saving new docs:" + itos (err));
3388
3397
3389
3398
print_line (" Deleting docs cache..." );
0 commit comments