You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-03 16:55:53 +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:
@@ -4338,10 +4338,7 @@ void EditorInspector::update_tree() {
|
||||
// `|` separators used in `EditorHelpBit`.
|
||||
if (theme_item_name.is_empty()) {
|
||||
if (p.name.contains("shader_parameter/")) {
|
||||
ShaderMaterial *shader_material = Object::cast_to<ShaderMaterial>(object);
|
||||
if (shader_material) {
|
||||
doc_tooltip_text = "property|" + shader_material->get_shader()->get_path() + "|" + propname;
|
||||
}
|
||||
doc_tooltip_text = "property|" + p.class_name + "|" + property_prefix + propname;
|
||||
} else if (p.usage & PROPERTY_USAGE_INTERNAL) {
|
||||
doc_tooltip_text = "internal_property|" + classname + "|" + propname;
|
||||
} else {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user