|
6 | 6 | *
|
7 | 7 | */
|
8 | 8 |
|
| 9 | +#include "AzCore/Script/ScriptContextAttributes.h" |
9 | 10 | #include <EditorPythonBindings/PythonUtility.h>
|
10 | 11 | #include <Source/PythonMarshalComponent.h>
|
11 | 12 | #include <Source/PythonProxyObject.h>
|
@@ -779,6 +780,23 @@ namespace EditorPythonBindings
|
779 | 780 | {
|
780 | 781 | namespace Internal
|
781 | 782 | {
|
| 783 | + AZStd::string ReadStringAttribute(const AZ::AttributeArray& attributes, const AZ::Crc32& attribute) |
| 784 | + { |
| 785 | + AZStd::string attributeValue = ""; |
| 786 | + if (auto attributeItem = azrtti_cast<AZ::AttributeData<AZStd::string>*>(AZ::FindAttribute(attribute, attributes))) |
| 787 | + { |
| 788 | + attributeValue = attributeItem->Get(nullptr); |
| 789 | + return attributeValue; |
| 790 | + } |
| 791 | + |
| 792 | + if (auto attributeItem = azrtti_cast<AZ::AttributeData<const char*>*>(AZ::FindAttribute(attribute, attributes))) |
| 793 | + { |
| 794 | + attributeValue = attributeItem->Get(nullptr); |
| 795 | + return attributeValue; |
| 796 | + } |
| 797 | + return {}; |
| 798 | + } |
| 799 | + |
782 | 800 | AZStd::string TypeNameFallback(const AZ::TypeId& typeId)
|
783 | 801 | {
|
784 | 802 | // fall back to class data m_name
|
@@ -1083,7 +1101,10 @@ namespace EditorPythonBindings
|
1083 | 1101 |
|
1084 | 1102 | //! Creates a string with class or global method definition and documentation.
|
1085 | 1103 | AZStd::string PythonBehaviorDescription::MethodDefinition(
|
1086 |
| - const AZStd::string methodName, const AZ::BehaviorMethod& behaviorMethod, const AZ::BehaviorClass* behaviorClass) |
| 1104 | + const AZStd::string methodName, |
| 1105 | + const AZ::BehaviorMethod& behaviorMethod, |
| 1106 | + const AZ::BehaviorClass* behaviorClass, |
| 1107 | + bool defineTooltip) |
1087 | 1108 | {
|
1088 | 1109 | AZStd::string buffer;
|
1089 | 1110 | AZStd::vector<AZStd::string> pythonArgs;
|
@@ -1138,13 +1159,27 @@ namespace EditorPythonBindings
|
1138 | 1159 | AZStd::string argsList;
|
1139 | 1160 | AzFramework::StringFunc::Join(buffer, pythonArgs.begin(), pythonArgs.end(), ",");
|
1140 | 1161 | AzFramework::StringFunc::Append(buffer, ") -> None:\n");
|
| 1162 | + |
| 1163 | + if (defineTooltip) |
| 1164 | + { |
| 1165 | + AZStd::string methodTooltip = Internal::ReadStringAttribute(behaviorMethod.m_attributes, AZ::Script::Attributes::ToolTip); |
| 1166 | + if (!methodTooltip.empty()) |
| 1167 | + { |
| 1168 | + Internal::AddCommentBlock(indentLevel + 1, methodTooltip, buffer); |
| 1169 | + } |
| 1170 | + } |
| 1171 | + |
1141 | 1172 | Internal::Indent(indentLevel + 1, buffer);
|
1142 | 1173 | AzFramework::StringFunc::Append(buffer, "pass\n\n");
|
1143 | 1174 | return buffer;
|
1144 | 1175 | }
|
1145 | 1176 |
|
1146 | 1177 | AZStd::string PythonBehaviorDescription::ClassDefinition(
|
1147 |
| - const AZ::BehaviorClass* behaviorClass, const AZStd::string className, bool defineProperties, bool defineMethods) |
| 1178 | + const AZ::BehaviorClass* behaviorClass, |
| 1179 | + const AZStd::string className, |
| 1180 | + bool defineProperties, |
| 1181 | + bool defineMethods, |
| 1182 | + bool defineTooltip) |
1148 | 1183 | {
|
1149 | 1184 | AZStd::string buffer;
|
1150 | 1185 | AzFramework::StringFunc::Append(buffer, "class ");
|
@@ -1197,7 +1232,7 @@ namespace EditorPythonBindings
|
1197 | 1232 | {
|
1198 | 1233 | AZStd::string baseMethodName{ methodEntry.first };
|
1199 | 1234 | Scope::FetchScriptName(method->m_attributes, baseMethodName);
|
1200 |
| - AZStd::string methodDef = MethodDefinition(baseMethodName, *method, behaviorClass); |
| 1235 | + AZStd::string methodDef = MethodDefinition(baseMethodName, *method, behaviorClass, defineTooltip); |
1201 | 1236 | AzFramework::StringFunc::Append(buffer, methodDef.c_str());
|
1202 | 1237 | }
|
1203 | 1238 | }
|
|
0 commit comments