summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-04-29 15:20:42 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-04-29 15:20:42 +0200
commit89850d553eeb259e208d0c577cd7bc1eabd3a90a (patch)
tree77207248ff1da2d821709bd7c8ab0aad2fe481e2
parentf03301ca1addda27b0c28c65749e21631da2ae97 (diff)
parent5bd9f4dea5dd0ee421ac6f464687cac107e0c02c (diff)
downloadredot-engine-89850d553eeb259e208d0c577cd7bc1eabd3a90a.tar.gz
Merge pull request #91307 from akien-mga/shader-doc-comments-fixup
Don't run Shader doc comments logic outside the editor
-rw-r--r--scene/resources/shader.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 296c914c65..0087a5e7f2 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -135,6 +135,7 @@ void Shader::get_shader_uniform_list(List<PropertyInfo> *p_params, bool p_get_gr
class_doc.name = get_path();
class_doc.is_script_doc = true;
#endif
+
for (PropertyInfo &pi : local) {
bool is_group = pi.usage == PROPERTY_USAGE_GROUP || pi.usage == PROPERTY_USAGE_SUBGROUP;
if (!p_get_groups && is_group) {
@@ -152,6 +153,8 @@ void Shader::get_shader_uniform_list(List<PropertyInfo> *p_params, bool p_get_gr
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
+ DocData::PropertyDoc prop_doc;
+ prop_doc.name = "shader_parameter/" + pi.name;
#ifdef MODULE_REGEX_ENABLED
const RegEx pattern("/\\*\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/\\s*uniform\\s+\\w+\\s+" + pi.name + "(?=[\\s:;=])");
Ref<RegExMatch> pattern_ref = pattern.search(code);
@@ -161,24 +164,17 @@ void Shader::get_shader_uniform_list(List<PropertyInfo> *p_params, bool p_get_gr
Ref<RegExMatch> pattern_tip_ref = pattern_tip.search(match->get_string(0));
RegExMatch *match_tip = pattern_tip_ref.ptr();
const RegEx pattern_stripped("\\n\\s*\\*\\s*");
- DocData::PropertyDoc prop_doc;
- prop_doc.name = "shader_parameter/" + pi.name;
prop_doc.description = pattern_stripped.sub(match_tip->get_string(1), "\n", true);
- class_doc.properties.push_back(prop_doc);
}
-#else
- DocData::PropertyDoc prop_doc;
- prop_doc.name = "shader_parameter/" + pi.name;
- // prop_doc.description = "(Regex module is not enabled, shader parameter documentation will not be available.)";
- 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 (!class_doc.name.is_empty() && p_params) {
+ if (Engine::get_singleton()->is_editor_hint() && !class_doc.name.is_empty() && p_params) {
EditorHelp::get_doc_data()->add_doc(class_doc);
}
#endif