@@ -178,6 +178,58 @@ def compile(self, namespace, name, id, args, has_flags):
178178 ["self.{0} = {0} # {1}" .format (i [0 ], i [1 ]) for i in args ]
179179 ) if args else "pass"
180180
181+ docstring_args = []
182+
183+ for i , arg in enumerate (sorted_args ):
184+ arg_name , arg_type = arg
185+ is_optional = arg_type .startswith ("flags." )
186+ arg_type = arg_type .split ("?" )[- 1 ]
187+
188+ if arg_type in core_types :
189+ if "int" in arg_type or arg_type == "long" :
190+ arg_type = "``int``"
191+ elif arg_type == "double" :
192+ arg_type = "``float``"
193+ else :
194+ arg_type = "``{}``" .format (arg_type .lower ())
195+ elif arg_type == "true" :
196+ arg_type = "``bool``"
197+ elif arg_type == "!X" :
198+ arg_type = "A function from :class:`pyrogram.api.functions`"
199+ else :
200+ if arg_type .startswith ("Vector" ):
201+ sub_type = arg_type .split ("<" )[1 ][:- 1 ]
202+
203+ if sub_type in core_types :
204+ arg_type = "List of ``{}``" .format (self .caml (sub_type ))
205+ else :
206+ arg_type = "List of :class:`pyrogram.api.types.{}`" .format (
207+ "." .join (
208+ arg_type .split ("." )[:- 1 ]
209+ + [self .caml (arg_type .split ("." )[- 1 ])]
210+ )
211+ )
212+ else :
213+ arg_type = ":class:`pyrogram.api.types.{}`" .format (
214+ "." .join (
215+ arg_type .split ("." )[:- 1 ]
216+ + [self .caml (arg_type .split ("." )[- 1 ])]
217+ )
218+ )
219+
220+ docstring_args .append (
221+ "{}: {}{}" .format (
222+ arg_name ,
223+ arg_type ,
224+ " (optional)" if is_optional else ""
225+ )
226+ )
227+
228+ if docstring_args :
229+ docstring_args = "Args:\n " + "\n " .join (docstring_args )
230+ else :
231+ docstring_args = "No parameters required."
232+
181233 if has_flags :
182234 write_flags = []
183235 for i in args :
@@ -268,6 +320,7 @@ def compile(self, namespace, name, id, args, has_flags):
268320 self .template .format (
269321 notice = self .notice ,
270322 class_name = self .caml (name ),
323+ docstring_args = docstring_args ,
271324 object_id = object_id ,
272325 arguments = arguments ,
273326 fields = fields ,
0 commit comments