diff options
Diffstat (limited to 'editor/doc_tools.cpp')
-rw-r--r-- | editor/doc_tools.cpp | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 91358c3475..7929c4b0ca 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -36,9 +36,9 @@ #include "core/io/compression.h" #include "core/io/dir_access.h" #include "core/io/marshalls.h" +#include "core/io/resource_importer.h" #include "core/object/script_language.h" #include "core/string/translation.h" -#include "core/version.h" #include "editor/editor_settings.h" #include "editor/export/editor_export.h" #include "scene/resources/theme.h" @@ -374,11 +374,6 @@ void DocTools::generate(bool p_basic_types) { classes.pop_front(); continue; } - if (ClassDB::get_api_type(name) != ClassDB::API_CORE && ClassDB::get_api_type(name) != ClassDB::API_EDITOR) { - print_verbose(vformat("Class '%s' belongs neither to core nor editor, skipping.", name)); - classes.pop_front(); - continue; - } String cname = name; // Property setters and getters do not get exposed as individual methods. @@ -392,7 +387,13 @@ void DocTools::generate(bool p_basic_types) { List<PropertyInfo> properties; List<PropertyInfo> own_properties; - // Special case for editor and project settings, so they can be documented. + // Special cases for editor/project settings, and ResourceImporter classes, + // we have to rely on Object's property list to get settings and import options. + // Otherwise we just use ClassDB's property list (pure registered properties). + + bool properties_from_instance = true; // To skip `script`, etc. + bool import_option = false; // Special case for default value. + HashMap<StringName, Variant> import_options_default; if (name == "EditorSettings") { // We don't create the full blown EditorSettings (+ config file) with `create()`, // instead we just make a local instance to get default values. @@ -402,7 +403,20 @@ void DocTools::generate(bool p_basic_types) { } else if (name == "ProjectSettings") { ProjectSettings::get_singleton()->get_property_list(&properties); own_properties = properties; + } else if (ClassDB::is_parent_class(name, "ResourceImporter") && name != "EditorImportPlugin" && ClassDB::can_instantiate(name)) { + import_option = true; + ResourceImporter *resimp = Object::cast_to<ResourceImporter>(ClassDB::instantiate(name)); + List<ResourceImporter::ImportOption> options; + resimp->get_import_options("", &options); + for (int i = 0; i < options.size(); i++) { + const PropertyInfo &prop = options[i].option; + properties.push_back(prop); + import_options_default[prop.name] = options[i].default_value; + } + own_properties = properties; + memdelete(resimp); } else if (name.begins_with("EditorExportPlatform") && ClassDB::can_instantiate(name)) { + properties_from_instance = false; Ref<EditorExportPlatform> platform = Object::cast_to<EditorExportPlatform>(ClassDB::instantiate(name)); if (platform.is_valid()) { List<EditorExportPlatform::ExportOption> options; @@ -413,6 +427,7 @@ void DocTools::generate(bool p_basic_types) { own_properties = properties; } } else { + properties_from_instance = false; ClassDB::get_property_list(name, &properties); ClassDB::get_property_list(name, &own_properties, true); } @@ -429,6 +444,13 @@ void DocTools::generate(bool p_basic_types) { EO = EO->next(); } + if (properties_from_instance) { + if (E.name == "resource_local_to_scene" || E.name == "resource_name" || E.name == "resource_path" || E.name == "script") { + // Don't include spurious properties from Object property list. + continue; + } + } + if (E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP || E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_INTERNAL || (E.type == Variant::NIL && E.usage & PROPERTY_USAGE_ARRAY)) { continue; } @@ -448,22 +470,9 @@ void DocTools::generate(bool p_basic_types) { bool default_value_valid = false; Variant default_value; - if (name == "EditorSettings") { - if (E.name == "resource_local_to_scene" || E.name == "resource_name" || E.name == "resource_path" || E.name == "script") { - // Don't include spurious properties in the generated EditorSettings class reference. - continue; - } - } - - if (name.begins_with("EditorExportPlatform")) { - if (E.name == "script") { - continue; - } - } - if (name == "ProjectSettings") { // Special case for project settings, so that settings are not taken from the current project's settings - if (E.name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E.name)) { + if (!ProjectSettings::get_singleton()->is_builtin_setting(E.name)) { continue; } if (E.usage & PROPERTY_USAGE_EDITOR) { @@ -472,6 +481,9 @@ void DocTools::generate(bool p_basic_types) { default_value_valid = true; } } + } else if (import_option) { + default_value = import_options_default[E.name]; + default_value_valid = true; } else { default_value = get_documentation_default_value(name, E.name, default_value_valid); if (inherited) { @@ -1487,7 +1499,6 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String, header += " is_experimental=\"true\""; } } - header += String(" version=\"") + VERSION_BRANCH + "\""; if (p_include_xml_schema) { // Reference the XML schema so editors can provide error checking. // Modules are nested deep, so change the path to reference the same schema everywhere. |