1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

Optimize the custom doc for shaders.

Remove add_doc for gdshader files without documentation.
Standardize the class_doc.name for custom documentation.
This commit is contained in:
Magian
2025-11-21 01:12:09 +08:00
parent 7864ac8019
commit 42c683d450
2 changed files with 12 additions and 11 deletions

View File

@@ -156,8 +156,12 @@ void Shader::get_shader_uniform_list(List<PropertyInfo> *p_params, bool p_get_gr
#ifdef TOOLS_ENABLED
DocData::ClassDoc class_doc;
class_doc.name = get_path();
class_doc.is_script_doc = true;
bool generate_doc = Engine::get_singleton()->is_editor_hint() && !get_path().is_empty();
if (generate_doc) {
class_doc.name = get_path().trim_prefix("res://").quote();
class_doc.is_script_doc = true;
class_doc.inherits = "Shader";
}
#endif
for (PropertyInfo &pi : local) {
@@ -176,10 +180,9 @@ void Shader::get_shader_uniform_list(List<PropertyInfo> *p_params, bool p_get_gr
pi.type = Variant::OBJECT;
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
if (generate_doc) {
DocData::PropertyDoc prop_doc;
prop_doc.name = "shader_parameter/" + pi.name;
#ifdef MODULE_REGEX_ENABLED
const RegEx pattern("/\\*\\*\\s([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/\\s*uniform\\s+\\w+\\s+" + pi.name + "(?=[\\s:;=])");
Ref<RegExMatch> pattern_ref = pattern.search(code);
if (pattern_ref.is_valid()) {
@@ -189,16 +192,17 @@ void Shader::get_shader_uniform_list(List<PropertyInfo> *p_params, bool p_get_gr
RegExMatch *match_tip = pattern_tip_ref.ptr();
const RegEx pattern_stripped("\\n\\s*\\*\\s*");
prop_doc.description = pattern_stripped.sub(match_tip->get_string(1), "\n", true);
pi.class_name = class_doc.name;
class_doc.properties.push_back(prop_doc);
}
#endif
class_doc.properties.push_back(prop_doc);
}
#endif
p_params->push_back(pi);
}
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && !class_doc.name.is_empty() && p_params) {
if (generate_doc && class_doc.properties.size() > 0) {
EditorHelp::add_doc(class_doc);
}
#endif