| 407 | } |
| 408 | |
| 409 | void DocTools::generate(BitField<GenerateFlags> p_flags) { |
| 410 | // This may involve instantiating classes that are only usable from the main thread |
| 411 | // (which is in fact the case of the core API). |
| 412 | ERR_FAIL_COND(!Thread::is_main_thread()); |
| 413 | |
| 414 | // Add ClassDB-exposed classes. |
| 415 | { |
| 416 | List<StringName> classes; |
| 417 | if (p_flags.has_flag(GENERATE_FLAG_EXTENSION_CLASSES_ONLY)) { |
| 418 | ClassDB::get_extensions_class_list(&classes); |
| 419 | } else { |
| 420 | ClassDB::get_class_list(&classes); |
| 421 | // Move ProjectSettings, so that other classes can register properties there. |
| 422 | classes.move_to_back(classes.find("ProjectSettings")); |
| 423 | } |
| 424 | |
| 425 | bool skip_setter_getter_methods = true; |
| 426 | |
| 427 | // Populate documentation data for each exposed class. |
| 428 | while (classes.size()) { |
| 429 | const String &name = classes.front()->get(); |
| 430 | if (!ClassDB::is_class_exposed(name)) { |
| 431 | print_verbose(vformat("Class '%s' is not exposed, skipping.", name)); |
| 432 | classes.pop_front(); |
| 433 | continue; |
| 434 | } |
| 435 | |
| 436 | const String &cname = name; |
| 437 | // Property setters and getters do not get exposed as individual methods. |
| 438 | HashSet<StringName> setters_getters; |
| 439 | |
| 440 | class_list[cname] = DocData::ClassDoc(); |
| 441 | DocData::ClassDoc &c = class_list[cname]; |
| 442 | c.name = cname; |
| 443 | c.inherits = ClassDB::get_parent_class(name); |
| 444 | |
| 445 | inheriting[c.inherits].insert(cname); |
| 446 | |
| 447 | List<PropertyInfo> properties; |
| 448 | List<PropertyInfo> own_properties; |
| 449 | |
| 450 | // Special cases for editor/project settings, and ResourceImporter classes, |
| 451 | // we have to rely on Object's property list to get settings and import options. |
| 452 | // Otherwise we just use ClassDB's property list (pure registered properties). |
| 453 | |
| 454 | bool properties_from_instance = true; // To skip `script`, etc. |
| 455 | bool import_option = false; // Special case for default value. |
| 456 | HashMap<StringName, Variant> import_options_default; |
| 457 | if (name == "EditorSettings") { |
| 458 | // We don't create the full blown EditorSettings (+ config file) with `create()`, |
| 459 | // instead we just make a local instance to get default values. |
| 460 | Ref<EditorSettings> edset = memnew(EditorSettings); |
| 461 | edset->get_property_list(&properties); |
| 462 | own_properties = properties; |
| 463 | } else if (name == "ProjectSettings") { |
| 464 | ProjectSettings::get_singleton()->get_property_list(&properties); |
| 465 | own_properties = properties; |
| 466 | } else if (ClassDB::is_parent_class(name, "ResourceImporter") && name != "EditorImportPlugin" && ClassDB::can_instantiate(name)) { |
no test coverage detected