Polish & fix editor help cache generation

- Isolated the generation of extensions's docs. They're now not cached and refreshed as needed.
- Removed superfluous sorting of the class list.
- Removed some superfluous/unused elements.
- Renamed some items for clarity.
This commit is contained in:
Pedro J. Estébanez 2023-10-31 18:27:17 +01:00
parent 93cdacbb0a
commit a1d8fc1af9
7 changed files with 71 additions and 49 deletions

View file

@ -355,20 +355,27 @@ static Variant get_documentation_default_value(const StringName &p_class_name, c
return default_value;
}
void DocTools::generate(bool p_basic_types) {
void DocTools::generate(BitField<GenerateFlags> p_flags) {
// This may involve instantiating classes that are only usable from the main thread
// (which is in fact the case of the core API).
ERR_FAIL_COND(!Thread::is_main_thread());
// Add ClassDB-exposed classes.
{
List<StringName> classes;
ClassDB::get_class_list(&classes);
classes.sort_custom<StringName::AlphCompare>();
// Move ProjectSettings, so that other classes can register properties there.
classes.move_to_back(classes.find("ProjectSettings"));
if (p_flags.has_flag(GENERATE_FLAG_EXTENSION_CLASSES_ONLY)) {
ClassDB::get_extensions_class_list(&classes);
} else {
ClassDB::get_class_list(&classes);
// Move ProjectSettings, so that other classes can register properties there.
classes.move_to_back(classes.find("ProjectSettings"));
}
bool skip_setter_getter_methods = true;
// Populate documentation data for each exposed class.
while (classes.size()) {
String name = classes.front()->get();
const String &name = classes.front()->get();
if (!ClassDB::is_class_exposed(name)) {
print_verbose(vformat("Class '%s' is not exposed, skipping.", name));
classes.pop_front();
@ -675,6 +682,10 @@ void DocTools::generate(bool p_basic_types) {
}
}
if (p_flags.has_flag(GENERATE_FLAG_SKIP_BASIC_TYPES)) {
return;
}
// Add a dummy Variant entry.
{
// This allows us to document the concept of Variant even though
@ -683,11 +694,6 @@ void DocTools::generate(bool p_basic_types) {
class_list["Variant"].name = "Variant";
}
// If we don't want to populate basic types, break here.
if (!p_basic_types) {
return;
}
// Add Variant data types.
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (i == Variant::NIL) {