Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Improvements #3428

Merged
merged 15 commits into from Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -136,8 +136,8 @@ Optional Dependencies
PTB can be installed with optional dependencies:

* ``pip install python-telegram-bot[passport]`` installs the `cryptography>=3.0 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
* ``pip install python-telegram-bot[socks]`` installs ``httpx[socks]``. Use this, if you want to work behind a Socks5 server.
* ``pip install python-telegram-bot[rate-limiter]`` installs ``aiolimiter~=1.0.0``. Use this, if you want to use ``telegram.ext.AIORateLimiter``.
* ``pip install python-telegram-bot[socks]`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
* ``pip install python-telegram-bot[rate-limiter]`` installs `aiolimiter~=1.0.0 <https://aiolimiter.readthedocs.io/en/stable/>`_. Use this, if you want to use ``telegram.ext.AIORateLimiter``.
* ``pip install python-telegram-bot[webhooks]`` installs the `tornado~=6.2 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.start_webhook``.
* ``pip install python-telegram-bot[callback-data]`` installs the `cachetools~=5.2.0 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_.
* ``pip install python-telegram-bot[job-queue]`` installs the `APScheduler~=3.9.1 <https://apscheduler.readthedocs.io/en/3.x/>`_ library and enforces `pytz>=2018.6 <https://pypi.org/project/pytz/>`_, where ``pytz`` is a dependency of ``APScheduler``. Use this, if you want to use the ``telegram.ext.JobQueue``.
Expand Down
2 changes: 1 addition & 1 deletion README_RAW.rst
Expand Up @@ -137,7 +137,7 @@ Optional Dependencies
PTB can be installed with optional dependencies:

* ``pip install python-telegram-bot-raw[passport]`` installs the `cryptography>=3.0 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
* ``pip install python-telegram-bot-raw[socks]`` installs ``httpx[socks]``. Use this, if you want to work behind a Socks5 server.
* ``pip install python-telegram-bot-raw[socks]`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.

To install multiple optional dependencies, separate them by commas, e.g. ``pip install python-telegram-bot-raw[passport,socks]``.

Expand Down
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
48 changes: 29 additions & 19 deletions telegram/_bot.py
Expand Up @@ -149,10 +149,8 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
.. seealso:: :attr:`telegram.ext.Application.bot`,
:attr:`telegram.ext.CallbackContext.bot`,
:attr:`telegram.ext.Updater.bot`,
`Your First Bot <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Extensions-–-Your-first-Bot>`_,
`Builder Pattern <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Builder-Pattern>`_
:wiki:`Your First Bot <Extensions-–-Your-first-Bot>`,
:wiki:`Builder Pattern <Builder-Pattern>`

.. versionadded:: 13.2
Objects of this class are comparable in terms of equality. Two objects of this class are
Expand Down Expand Up @@ -909,7 +907,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 +1017,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 +1139,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 +1249,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 +1345,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 +1471,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 +1594,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 +1720,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 +1830,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 +2671,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 +2820,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 +3313,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 Expand Up @@ -3556,9 +3566,9 @@ async def set_webhook(
integration.
certificate (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`):
Upload your public key certificate so that the root
certificate in use can be checked. See our `self-signed guide <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Webhooks#creating-a-self-signed-\
certificate-using-openssl>`_ for details. |uploadinputnopath|
certificate in use can be checked. See our :wiki:`self-signed guide\
<Webhooks#creating-a-self-signed-certificate-using-openssl>` for details.
|uploadinputnopath|
ip_address (:obj:`str`, optional): The fixed IP address which will be used to send
webhook requests instead of the IP address resolved through DNS.
max_connections (:obj:`int`, optional): Maximum allowed number of simultaneous HTTPS
Expand Down
2 changes: 1 addition & 1 deletion telegram/_chatmember.py
Expand Up @@ -45,7 +45,7 @@ class ChatMember(TelegramObject):
considered equal, if their :attr:`user` and :attr:`status` are equal.

Examples:
:any:`Chat Member Bot <examples.chatmemberbot>`
:any:`Chat Member Bot <examples.chatmemberbot>`

.. versionchanged:: 20.0

Expand Down
4 changes: 2 additions & 2 deletions telegram/_dice.py
Expand Up @@ -52,8 +52,8 @@ class Dice(TelegramObject):

If :attr:`emoji` is :tg-const:`telegram.Dice.SLOT_MACHINE`, each value
corresponds to a unique combination of symbols, which
can be found at our `wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki\
/Code-snippets#map-a-slot-machine-dice-value-to-the-corresponding-symbols>`_.
can be found in our
:wiki:`wiki <Code-snippets#map-a-slot-machine-dice-value-to-the-corresponding-symbols>`.
However, this behaviour is undocumented and might be changed by Telegram.

..
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
3 changes: 1 addition & 2 deletions telegram/_inline/inlinekeyboardbutton.py
Expand Up @@ -95,8 +95,7 @@ class InlineKeyboardButton(TelegramObject):
Tip:
The value entered here will be available in :attr:`telegram.CallbackQuery.data`.

.. seealso:: `Arbitrary callback_data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_
.. seealso:: :wiki:`Arbitrary callback_data <Arbitrary-callback_data>`

web_app (:obj:`telegram.WebAppInfo`, optional): Description of the `Web App
<https://core.telegram.org/bots/webapps>`_ that will be launched when the user presses
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