@@ -939,6 +939,7 @@ TExposedMethodImplementation = class(TAbstractExposedMemberImplementation)
939
939
940
940
function VirtualMethodImplementation (): pointer;
941
941
942
+ class function MethodDocStr (const ARttiMethod: TRttiMethod): string;
942
943
class function Methods_Wrapper (const ASelf, AArgs, AKeyWords: PPyObject): PPyObject; static; cdecl;
943
944
944
945
property MethodHandler: TExposedMethodHandler read FMethodHandler write FMethodHandler;
@@ -1138,6 +1139,42 @@ function TExposedMethodImplementation.GetDocString(): string;
1138
1139
Name , FRttiType.Name , NativeInt(Self)]);
1139
1140
end ;
1140
1141
1142
+ class function TExposedMethodImplementation.MethodDocStr
1143
+ (const ARttiMethod: TRttiMethod): string;
1144
+ const
1145
+ METHOD_DOC_STR_PATTERN = ' %s.%s(%s)' ;
1146
+ var
1147
+ LArgsStr: string;
1148
+ LRttiParameter: TRttiParameter;
1149
+ begin
1150
+ if (Length(ARttiMethod.GetParameters) = 0 ) then
1151
+ Exit(String.Empty);
1152
+
1153
+ LArgsStr := String.Empty;
1154
+ for LRttiParameter in ARttiMethod.GetParameters do begin
1155
+ if not LArgsStr.IsEmpty then
1156
+ LArgsStr := LArgsStr + ' , ' ;
1157
+
1158
+ if not Assigned(LRttiParameter.ParamType) then
1159
+ LArgsStr := LArgsStr + LRttiParameter.Name
1160
+ else
1161
+ LArgsStr := LArgsStr
1162
+ + LRttiParameter.Name
1163
+ + ' : '
1164
+ + LRttiParameter.ParamType.Name .Replace(' T' , ' ' , []);
1165
+ end ;
1166
+
1167
+ Result := String.Format(METHOD_DOC_STR_PATTERN, [
1168
+ ARttiMethod.Parent.Name , ARttiMethod.Name , LArgsStr]);
1169
+
1170
+ if Assigned(ARttiMethod.ReturnType) then
1171
+ Result := Result
1172
+ + ' -> '
1173
+ + ARttiMethod.ReturnType.Name .Replace(' T' , ' ' , []);
1174
+
1175
+ Result := Result + #10 ;
1176
+ end ;
1177
+
1141
1178
function TExposedMethodImplementation.VirtualMethodImplementation (): pointer;
1142
1179
var
1143
1180
LRttiCtx: TRttiContext;
@@ -3400,6 +3437,11 @@ class procedure TPyDelphiObject.ExposeMethods(const AClass: TClass;
3400
3437
LClass := LClass.ClassParent;
3401
3438
end ;
3402
3439
3440
+ // Build the DocStr including method args
3441
+ LExposedMethod.DocString :=
3442
+ AnsiString(TExposedMethodImplementation.MethodDocStr(LRttiMethod))
3443
+ + LExposedMethod.DocString;
3444
+
3403
3445
// Adds the Python method
3404
3446
if LRttiMethod.IsStatic then
3405
3447
APythonType.AddStaticMethodWithKeywords(
0 commit comments