Skip to content

Commit 3a77baf

Browse files
Add parameter documentation
Signed-off-by: Artur Kamieniecki <[email protected]>
1 parent c68ade6 commit 3a77baf

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

Gems/EditorPythonBindings/Code/Include/EditorPythonBindings/PythonUtility.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,18 @@ namespace EditorPythonBindings
154154
AZStd::string BusDefinition(const AZStd::string busName, const AZ::BehaviorEBus* behaviorEBus);
155155

156156
//! Creates a string with class or global method definition and documentation.
157+
//! @param defineTooltip if true, the tooltip will be included in the definition
157158
AZStd::string MethodDefinition(
158159
const AZStd::string methodName,
159160
const AZ::BehaviorMethod& behaviorMethod,
160161
const AZ::BehaviorClass* behaviorClass = nullptr,
161-
bool defineTooltip = false);
162+
bool defineTooltip = false,
163+
bool defineDebugDescription = false);
162164

163165
//! Creates a string with class definition and documentation.
166+
//! @param defineProperties if true, the properties will be included in the definition
167+
//! @param defineMethods if true, the methods will be included in the definition
168+
//! @param defineTooltip if true, the tooltip will be included in the definition
164169
AZStd::string ClassDefinition(
165170
const AZ::BehaviorClass* behaviorClass,
166171
const AZStd::string className,

Gems/EditorPythonBindings/Code/Source/PythonUtility.cpp

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,10 @@ namespace EditorPythonBindings
10391039

10401040
// record the event names the behavior can send, their parameters and return type
10411041
AZStd::string comment = behaviorEBus->m_toolTip;
1042+
if (comment.empty())
1043+
{
1044+
comment = Internal::ReadStringAttribute(behaviorEBus->m_attributes, AZ::Script::Attributes::ToolTip);
1045+
}
10421046

10431047
if (!behaviorEBus->m_events.empty())
10441048
{
@@ -1104,7 +1108,8 @@ namespace EditorPythonBindings
11041108
const AZStd::string methodName,
11051109
const AZ::BehaviorMethod& behaviorMethod,
11061110
const AZ::BehaviorClass* behaviorClass,
1107-
bool defineTooltip)
1111+
bool defineTooltip,
1112+
bool defineDebugDescription)
11081113
{
11091114
AZStd::string buffer;
11101115
AZStd::vector<AZStd::string> pythonArgs;
@@ -1160,14 +1165,30 @@ namespace EditorPythonBindings
11601165
AzFramework::StringFunc::Join(buffer, pythonArgs.begin(), pythonArgs.end(), ",");
11611166
AzFramework::StringFunc::Append(buffer, ") -> None:\n");
11621167

1168+
AZStd::string methodTooltipAndDebugDescription = "";
1169+
1170+
if (defineDebugDescription && behaviorMethod.m_debugDescription != nullptr)
1171+
{
1172+
AZStd::string debugDescription(behaviorMethod.m_debugDescription);
1173+
if (!debugDescription.empty())
1174+
{
1175+
methodTooltipAndDebugDescription += debugDescription;
1176+
methodTooltipAndDebugDescription += "\n";
1177+
}
1178+
}
11631179
if (defineTooltip)
11641180
{
11651181
AZStd::string methodTooltip = Internal::ReadStringAttribute(behaviorMethod.m_attributes, AZ::Script::Attributes::ToolTip);
11661182
if (!methodTooltip.empty())
11671183
{
1168-
Internal::AddCommentBlock(indentLevel + 1, methodTooltip, buffer);
1184+
methodTooltipAndDebugDescription += methodTooltip;
1185+
methodTooltipAndDebugDescription += "\n";
11691186
}
11701187
}
1188+
if (!methodTooltipAndDebugDescription.empty())
1189+
{
1190+
Internal::AddCommentBlock(indentLevel + 1, methodTooltipAndDebugDescription, buffer);
1191+
}
11711192

11721193
Internal::Indent(indentLevel + 1, buffer);
11731194
AzFramework::StringFunc::Append(buffer, "pass\n\n");
@@ -1205,6 +1226,16 @@ namespace EditorPythonBindings
12051226
{
12061227
body = "";
12071228
}
1229+
if (defineTooltip)
1230+
{
1231+
AZStd::string classTooltip =
1232+
Internal::ReadStringAttribute(behaviorClass->m_attributes, AZ::Script::Attributes::ToolTip);
1233+
if (!classTooltip.empty())
1234+
{
1235+
Internal::AddCommentBlock(1, classTooltip, body);
1236+
}
1237+
}
1238+
12081239
Internal::Indent(1, body);
12091240
AzFramework::StringFunc::Append(body, "pass\n\n");
12101241
AzFramework::StringFunc::Append(buffer, body.c_str());

0 commit comments

Comments
 (0)