From bab9359df843ceacf944e7e16571e575c8f77913 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 26 Aug 2020 09:07:54 +0200 Subject: [PATCH] Use a better way to document properties --- compiler/docs/compiler.py | 1 - pyrogram/types/messages_and_media/message.py | 40 ++++++++++---------- pyrogram/types/user_and_chats/user.py | 11 +++--- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 54fd9b9f..fdb4972d 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -417,7 +417,6 @@ def pyrogram_api(): f2.write(title + "\n" + "=" * len(title) + "\n\n") f2.write(".. autoclass:: pyrogram.types.{}()\n".format(type)) - f2.write(" :members:\n") f.write(template.format(**fmt_keys)) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 9950df4a..0fad3f41 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -257,6 +257,9 @@ class Message(Object, Update): reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*): Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + + link (``str``, *property*): + Generate a link to this message, only for groups and channels. """ # TODO: Add game missing field. Also invoice, successful_payment, connected_website @@ -672,7 +675,6 @@ class Message(Object, Update): @property def link(self) -> str: - """Generate a link to this message, only for groups and channels.""" if self.chat.type in ("group", "supergroup", "channel") and self.chat.username: return f"https://t.me/{self.chat.username}/{self.message_id}" else: @@ -868,8 +870,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the sent :obj:`~pyrogram.types.Message` is returned. @@ -1011,8 +1013,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the sent :obj:`~pyrogram.types.Message` is returned. @@ -1355,8 +1357,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the sent :obj:`~pyrogram.types.Message` is returned. @@ -1756,8 +1758,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the sent :obj:`~pyrogram.types.Message` is returned. @@ -1940,8 +1942,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the sent :obj:`~pyrogram.types.Message` is returned. @@ -2179,8 +2181,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the sent :obj:`~pyrogram.types.Message` is returned. @@ -2307,8 +2309,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the sent :obj:`~pyrogram.types.Message` is returned. @@ -2432,8 +2434,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the sent :obj:`~pyrogram.types.Message` is returned. @@ -3052,8 +3054,8 @@ class Message(Object, Update): The total size of the file. *args (``tuple``, *optional*): - Extra custom arguments as defined in the *progress_args* parameter. - You can either keep *\*args* or add every single extra argument in your function signature. + Extra custom arguments as defined in the ``progress_args`` parameter. + You can either keep ``*args`` or add every single extra argument in your function signature. Returns: On success, the absolute path of the downloaded file as string is returned, None otherwise. diff --git a/pyrogram/types/user_and_chats/user.py b/pyrogram/types/user_and_chats/user.py index 7174a3d4..f1595760 100644 --- a/pyrogram/types/user_and_chats/user.py +++ b/pyrogram/types/user_and_chats/user.py @@ -138,6 +138,12 @@ class User(Object, Update): restrictions (List of :obj:`~pyrogram.types.Restriction`, *optional*): The list of reasons why this bot might be unavailable to some users. This field is available only in case *is_restricted* is True. + + mention (``str``, *property*): + Generate a text mention for this user. + You can use ``user.mention()`` to mention the user using their first name (styled using html), or + ``user.mention("another name")`` for a custom name. To choose a different style + ("html" or "md"/"markdown") use ``user.mention(style="md")``. """ def __init__( @@ -192,11 +198,6 @@ class User(Object, Update): @property def mention(self): - """Generate a text mention for this user. - - You can use ``user.mention()`` to mention the user using their first name (styled using html), or - ``user.mention("another name")`` for a custom name. To choose a different style - ("html" or "md"/"markdown") use ``user.mention(style="md")``.""" return Link(f"tg://user?id={self.id}", self.first_name, self._client.parse_mode) @staticmethod