Skip to content

Commit

Permalink
Add links to "Working with Files and Media" wiki page from docstrings (
Browse files Browse the repository at this point in the history
…#3423)

Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Viicos <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
  • Loading branch information
4 people committed Dec 16, 2022
1 parent 9467847 commit 33fd250
Show file tree
Hide file tree
Showing 20 changed files with 92 additions and 13 deletions.
4 changes: 4 additions & 0 deletions docs/source/conf.py
Expand Up @@ -44,11 +44,15 @@
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.linkcode",
"sphinx.ext.extlinks",
"sphinx_paramlinks",
"sphinxcontrib.mermaid",
"sphinx_search.extension",
]

# For shorter links to Wiki in docstrings
extlinks = {"wiki": ("https://github.com/python-telegram-bot/python-telegram-bot/wiki/%s", "%s")}

# Use intersphinx to reference the python builtin library docs
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
Expand Down
36 changes: 24 additions & 12 deletions telegram/_bot.py
Expand Up @@ -909,7 +909,8 @@ async def send_photo(
"""Use this method to send photos.
.. seealso:: :meth:`telegram.Message.reply_photo`, :meth:`telegram.Chat.send_photo`,
:meth:`telegram.User.send_photo`
:meth:`telegram.User.send_photo`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -1018,7 +1019,8 @@ async def send_audio(
For sending voice messages, use the :meth:`send_voice` method instead.
.. seealso:: :meth:`telegram.Message.reply_audio`, :meth:`telegram.Chat.send_audio`,
:meth:`telegram.User.send_audio`
:meth:`telegram.User.send_audio`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -1139,7 +1141,8 @@ async def send_document(
changed in the future.
.. seealso:: :meth:`telegram.Message.reply_document`, :meth:`telegram.Chat.send_document`,
:meth:`telegram.User.send_document`
:meth:`telegram.User.send_document`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -1248,7 +1251,8 @@ async def send_sticker(
Use this method to send static ``.WEBP``, animated ``.TGS``, or video ``.WEBM`` stickers.
.. seealso:: :meth:`telegram.Message.reply_sticker`, :meth:`telegram.Chat.send_sticker`,
:meth:`telegram.User.send_sticker`
:meth:`telegram.User.send_sticker`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -1343,7 +1347,8 @@ async def send_video(
changed by Telegram.
.. seealso:: :meth:`telegram.Message.reply_video`, :meth:`telegram.Chat.send_video`,
:meth:`telegram.User.send_video`
:meth:`telegram.User.send_video`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -1468,7 +1473,8 @@ async def send_video_note(
.. seealso:: :meth:`telegram.Message.reply_video_note`,
:meth:`telegram.Chat.send_video_note`,
:meth:`telegram.User.send_video_note`
:meth:`telegram.User.send_video_note`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -1590,7 +1596,8 @@ async def send_animation(
.. seealso:: :meth:`telegram.Message.reply_animation`,
:meth:`telegram.Chat.send_animation`,
:meth:`telegram.User.send_animation`
:meth:`telegram.User.send_animation`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -1715,7 +1722,8 @@ async def send_voice(
sent as files.
.. seealso:: :meth:`telegram.Message.reply_voice`, :meth:`telegram.Chat.send_voice`,
:meth:`telegram.User.send_voice`
:meth:`telegram.User.send_voice`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -1824,7 +1832,8 @@ async def send_media_group(
.. seealso:: :meth:`telegram.Message.reply_media_group`,
:meth:`telegram.Chat.send_media_group`,
:meth:`telegram.User.send_media_group`
:meth:`telegram.User.send_media_group`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
Expand Down Expand Up @@ -2664,7 +2673,8 @@ async def answer_inline_query(
:paramref:`telegram.InlineQuery.answer.auto_pagination` set to :obj:`True`, which will
take care of passing the correct value.
.. seealso:: :meth:`telegram.InlineQuery.answer`
.. seealso:: :meth:`telegram.InlineQuery.answer`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
inline_query_id (:obj:`str`): Unique identifier for the answered query.
Expand Down Expand Up @@ -2812,7 +2822,8 @@ async def get_file(
:meth:`telegram.Document.get_file`, :meth:`telegram.PassportFile.get_file`,
:meth:`telegram.PhotoSize.get_file`, :meth:`telegram.Sticker.get_file`,
:meth:`telegram.Video.get_file`, :meth:`telegram.VideoNote.get_file`,
:meth:`telegram.Voice.get_file`
:meth:`telegram.Voice.get_file`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
file_id (:obj:`str` | :class:`telegram.Animation` | :class:`telegram.Audio` | \
Expand Down Expand Up @@ -3304,7 +3315,8 @@ async def edit_message_media(
|editreplymarkup|
.. seealso:: :meth:`telegram.Message.edit_media`,
:meth:`telegram.CallbackQuery.edit_message_media`
:meth:`telegram.CallbackQuery.edit_message_media`,
:wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
media (:class:`telegram.InputMedia`): An object for a new media content
Expand Down
4 changes: 4 additions & 0 deletions telegram/_files/file.py
Expand Up @@ -141,6 +141,8 @@ async def download_to_drive(
original file in order to decrypt the file without changing the existing one
in-place.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
.. versionchanged:: 20.0
* :paramref:`custom_path` parameter now also accepts :class:`pathlib.Path` as argument.
Expand Down Expand Up @@ -224,6 +226,8 @@ async def download_to_memory(
:obj:`io.BufferedIOBase`, the file contents will be saved to that object using the
:obj:`out.write<io.BufferedIOBase.write>` method.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
.. versionadded:: 20.0
Args:
Expand Down
12 changes: 12 additions & 0 deletions telegram/_files/inputmedia.py
Expand Up @@ -44,6 +44,8 @@ class InputMedia(TelegramObject):
Added arguments and attributes :attr:`type`, :attr:`media`, :attr:`caption`,
:attr:`caption_entities`, :paramref:`parse_mode`.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
media_type (:obj:`str`): Type of media that the instance represents.
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
Expand Down Expand Up @@ -115,6 +117,8 @@ class InputMediaAnimation(InputMedia):
width, height and duration from that video, unless otherwise specified with the optional
arguments.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
:class:`telegram.Animation`): File to send. |fileinputnopath|
Expand Down Expand Up @@ -208,6 +212,8 @@ def __init__(
class InputMediaPhoto(InputMedia):
"""Represents a photo to be sent.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
:class:`telegram.PhotoSize`): File to send. |fileinputnopath|
Expand Down Expand Up @@ -273,6 +279,8 @@ def __init__(
class InputMediaVideo(InputMedia):
"""Represents a video to be sent.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Note:
* When using a :class:`telegram.Video` for the :attr:`media` attribute, it will take the
width, height and duration from that video, unless otherwise specified with the optional
Expand Down Expand Up @@ -380,6 +388,8 @@ def __init__(
class InputMediaAudio(InputMedia):
"""Represents an audio file to be treated as music to be sent.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Note:
When using a :class:`telegram.Audio` for the :attr:`media` attribute, it will take the
duration, performer and title from that video, unless otherwise specified with the
Expand Down Expand Up @@ -479,6 +489,8 @@ def __init__(
class InputMediaDocument(InputMedia):
"""Represents a general file to be sent.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
:class:`telegram.Document`): File to send. |fileinputnopath|
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultaudio.py
Expand Up @@ -37,6 +37,8 @@ class InlineQueryResultAudio(InlineQueryResult):
Alternatively, you can use :attr:`input_message_content` to send a message with the specified
content instead of the audio.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultcachedaudio.py
Expand Up @@ -37,6 +37,8 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
file will be sent by the user. Alternatively, you can use :attr:`input_message_content` to
send a message with the specified content instead of the audio.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultcacheddocument.py
Expand Up @@ -37,6 +37,8 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
by the user with an optional caption. Alternatively, you can use :attr:`input_message_content`
to send a message with the specified content instead of the file.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultcachedgif.py
Expand Up @@ -38,6 +38,8 @@ class InlineQueryResultCachedGif(InlineQueryResult):
use :attr:`input_message_content` to send a message with specified content instead of
the animation.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultcachedmpeg4gif.py
Expand Up @@ -38,6 +38,8 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
optional caption. Alternatively, you can use :attr:`input_message_content` to send a message
with the specified content instead of the animation.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultcachedphoto.py
Expand Up @@ -38,6 +38,8 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
:attr:`input_message_content` to send a message with the specified content instead
of the photo.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultcachedsticker.py
Expand Up @@ -35,6 +35,8 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
be sent by the user. Alternatively, you can use :attr:`input_message_content` to send a
message with the specified content instead of the sticker.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultcachedvideo.py
Expand Up @@ -38,6 +38,8 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
:attr:`input_message_content` to send a message with the specified content instead
of the video.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultcachedvoice.py
Expand Up @@ -37,6 +37,8 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
message will be sent by the user. Alternatively, you can use :attr:`input_message_content` to
send a message with the specified content instead of the voice message.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultdocument.py
Expand Up @@ -38,6 +38,8 @@ class InlineQueryResultDocument(InlineQueryResult):
specified content instead of the file. Currently, only .PDF and .ZIP files can be sent
using this method.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultgif.py
Expand Up @@ -37,6 +37,8 @@ class InlineQueryResultGif(InlineQueryResult):
the user with optional caption. Alternatively, you can use :attr:`input_message_content` to
send a message with the specified content instead of the animation.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultmpeg4gif.py
Expand Up @@ -38,6 +38,8 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
use :attr:`input_message_content` to send a message with the specified content instead of the
animation.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultphoto.py
Expand Up @@ -37,6 +37,8 @@ class InlineQueryResultPhoto(InlineQueryResult):
caption. Alternatively, you can use :attr:`input_message_content` to send a message with the
specified content instead of the photo.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultvideo.py
Expand Up @@ -42,6 +42,8 @@ class InlineQueryResultVideo(InlineQueryResult):
If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must
replace its content using :attr:`input_message_content`.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresultvoice.py
Expand Up @@ -38,6 +38,8 @@ class InlineQueryResultVoice(InlineQueryResult):
:attr:`input_message_content` to send a message with the specified content instead of
the voice message.
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Args:
id (:obj:`str`): Unique identifier for this result,
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
Expand Down

0 comments on commit 33fd250

Please sign in to comment.