Documentation Improvements (#3803, #3797, #3816, #3829)

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Dmitry K <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Trim21 <trim21.me@gmail.com>
Co-authored-by: aelkheir <90580077+aelkheir@users.noreply.github.com>
This commit is contained in:
Bibo-Joshi 2023-09-03 14:13:19 +02:00 committed by GitHub
parent 644d76b592
commit 40ab8aadca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 83 additions and 41 deletions

View file

@ -167,6 +167,7 @@ Feel free to copy (parts of) the checklist to the PR description to remind you o
**If the PR contains API changes (otherwise, you can ignore this passage)**
- Checked the Bot API specific sections of the `Stability Policy <https://docs.python-telegram-bot.org/stability_policy.html>`_
- Created a PR to remove functionality deprecated in the previous Bot API release (`see here <https://docs.python-telegram-bot.org/en/stable/stability_policy.html#case-2>`_)
- New classes:

View file

@ -1,6 +1,6 @@
<!--
Hey! You're PRing? Cool!
Please be sure to check out our contribution guide (https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst).
Especially, please have a look at the check list for PRs (https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst#checklist-for-prs). Feel free to copy (parts of) the checklist to the PR description to remind you or the maintainers of open points or if you have questions on anything.
Especially, please have a look at the check list for PRs (https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst#check-list-for-prs). Feel free to copy (parts of) the checklist to the PR description to remind you or the maintainers of open points or if you have questions on anything.
-->

View file

@ -21,6 +21,7 @@ Contributors
The following wonderful people contributed directly or indirectly to this project:
- `Abdelrahman <https://github.com/aelkheir>`_
- `Abshar <https://github.com/abxhr>`_
- `Alateas <https://github.com/alateas>`_
- `Ales Dokshanin <https://github.com/alesdokshanin>`_

View file

@ -30,7 +30,7 @@
:target: https://www.gnu.org/licenses/lgpl-3.0.html
:alt: LGPLv3 License
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/GitHub%20Actions/badge.svg
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/Unit%20Tests/badge.svg
:target: https://github.com/python-telegram-bot/python-telegram-bot/
:alt: Github Actions workflow

View file

@ -30,7 +30,7 @@
:target: https://www.gnu.org/licenses/lgpl-3.0.html
:alt: LGPLv3 License
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/GitHub%20Actions/badge.svg
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/Unit%20Tests/badge.svg
:target: https://github.com/python-telegram-bot/python-telegram-bot/
:alt: Github Actions workflow

View file

@ -42,7 +42,7 @@ keyword_args = [
]
write_timeout_sub = [":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`", "``20``"]
read_timeout_sub = [
":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`",
"``2``. :paramref:`timeout` will be added to this value",
]
read_timeout_type = [":obj:`float` | :obj:`None`", ":obj:`float`"]

View file

@ -1,7 +1,7 @@
sphinx==7.2.5
sphinx-pypi-upload
furo==2023.8.19
git+https://github.com/harshil21/furo-sphinx-search@01efc7be422d7dc02390aab9be68d6f5ce1a5618#egg=furo-sphinx-search
git+https://github.com/harshil21/furo-sphinx-search@v0.2.0.1
sphinx-paramlinks==0.6.0
sphinxcontrib-mermaid==0.9.2
sphinx-copybutton==0.5.2

View file

@ -23,7 +23,7 @@ author = "Leandro Toledo"
# The short X.Y version.
version = "20.4" # telegram.__version__[:3]
# The full version, including alpha/beta/rc tags.
release = "20.3" # telegram.__version__
release = "20.4" # telegram.__version__
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = "6.1.3"

View file

@ -57,3 +57,5 @@
.. |captionentitiesattr| replace:: Tuple of special entities that appear in the caption, which can be specified instead of ``parse_mode``.
.. |datetime_localization| replace:: The default timezone of the bot is used for localization, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is used.
.. |post_methods_note| replace:: If you implement custom logic that implies that you will **not** be using :class:`~telegram.ext.Application`'s methods :meth:`~telegram.ext.Application.run_polling` or :meth:`~telegram.ext.Application.run_webhook` to run your application (like it's done in `Custom Webhook Bot Example <https://docs.python-telegram-bot.org/en/stable/examples.customwebhookbot.html>`__), the callback you set in this method **will not be called automatically**. So instead of setting a callback with this method, you have to explicitly ``await`` the function that you want to run at this stage of your application's life (in the `example mentioned above <https://docs.python-telegram-bot.org/en/stable/examples.customwebhookbot.html>`__, that would be in ``async with application`` context manager).

View file

@ -40,11 +40,13 @@ class MessageEntity(TelegramObject):
Args:
type (:obj:`str`): Type of the entity. Can be :attr:`MENTION` (@username),
:attr:`HASHTAG`, :attr:`BOT_COMMAND`,
:attr:`URL`, :attr:`EMAIL`, :attr:`PHONE_NUMBER`, :attr:`BOLD` (bold text),
:attr:`ITALIC` (italic text), :attr:`STRIKETHROUGH`, :attr:`SPOILER` (spoiler message),
:attr:`CODE` (monowidth string), :attr:`PRE` (monowidth block), :attr:`TEXT_LINK` (for
clickable text URLs), :attr:`TEXT_MENTION` (for users without usernames),
:attr:`HASHTAG` (#hashtag), :attr:`CASHTAG` ($USD), :attr:`BOT_COMMAND`
(/start@jobs_bot), :attr:`URL` (https://telegram.org),
:attr:`EMAIL` (do-not-reply@telegram.org), :attr:`PHONE_NUMBER` (+1-212-555-0123),
:attr:`BOLD` (**bold text**), :attr:`ITALIC` (*italic text*), :attr:`UNDERLINE`
(underlined text), :attr:`STRIKETHROUGH`, :attr:`SPOILER` (spoiler message),
:attr:`CODE` (monowidth string), :attr:`PRE` (monowidth block), :attr:`TEXT_LINK`
(for clickable text URLs), :attr:`TEXT_MENTION` (for users without usernames),
:attr:`CUSTOM_EMOJI` (for inline custom emoji stickers).
.. versionadded:: 20.0
@ -64,11 +66,13 @@ class MessageEntity(TelegramObject):
.. versionadded:: 20.0
Attributes:
type (:obj:`str`): Type of the entity. Can be :attr:`MENTION` (@username),
:attr:`HASHTAG`, :attr:`BOT_COMMAND`,
:attr:`URL`, :attr:`EMAIL`, :attr:`PHONE_NUMBER`, :attr:`BOLD` (bold text),
:attr:`ITALIC` (italic text), :attr:`STRIKETHROUGH`, :attr:`SPOILER` (spoiler message),
:attr:`CODE` (monowidth string), :attr:`PRE` (monowidth block), :attr:`TEXT_LINK` (for
clickable text URLs), :attr:`TEXT_MENTION` (for users without usernames),
:attr:`HASHTAG` (#hashtag), :attr:`CASHTAG` ($USD), :attr:`BOT_COMMAND`
(/start@jobs_bot), :attr:`URL` (https://telegram.org),
:attr:`EMAIL` (do-not-reply@telegram.org), :attr:`PHONE_NUMBER` (+1-212-555-0123),
:attr:`BOLD` (**bold text**), :attr:`ITALIC` (*italic text*), :attr:`UNDERLINE`
(underlined text), :attr:`STRIKETHROUGH`, :attr:`SPOILER` (spoiler message),
:attr:`CODE` (monowidth string), :attr:`PRE` (monowidth block), :attr:`TEXT_LINK`
(for clickable text URLs), :attr:`TEXT_MENTION` (for users without usernames),
:attr:`CUSTOM_EMOJI` (for inline custom emoji stickers).
.. versionadded:: 20.0

View file

@ -127,6 +127,9 @@ class NetworkError(TelegramError):
Examples:
:any:`Raw API Bot <examples.rawapibot>`
.. seealso::
:wiki:`Handling network errors <Handling-network-errors>`
"""
__slots__ = ()
@ -141,6 +144,9 @@ class BadRequest(NetworkError):
class TimedOut(NetworkError):
"""Raised when a request took too long to finish.
.. seealso::
:wiki:`Handling network errors <Handling-network-errors>`
Args:
message (:obj:`str`, optional): Any additional information about the exception.

View file

@ -693,7 +693,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
On unix, the app will also shut down on receiving the signals specified by
:paramref:`stop_signals`.
The order of execution by `run_polling` is roughly as follows:
The order of execution by :meth:`run_polling` is roughly as follows:
- :meth:`initialize`
- :meth:`post_init`
@ -708,11 +708,6 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
.. include:: inclusions/application_run_tip.rst
.. seealso::
:meth:`initialize`, :meth:`start`, :meth:`stop`, :meth:`shutdown`
:meth:`telegram.ext.Updater.start_polling`, :meth:`telegram.ext.Updater.stop`,
:meth:`run_webhook`
Args:
poll_interval (:obj:`float`, optional): Time to wait between polling updates from
Telegram in seconds. Default is ``0.0``.
@ -816,7 +811,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
``https://listen:port/url_path``. Also calls :meth:`telegram.Bot.set_webhook` as
required.
The order of execution by `run_webhook` is roughly as follows:
The order of execution by :meth:`run_webhook` is roughly as follows:
- :meth:`initialize`
- :meth:`post_init`
@ -840,9 +835,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
.. include:: inclusions/application_run_tip.rst
.. seealso::
:meth:`initialize`, :meth:`start`, :meth:`stop`, :meth:`shutdown`
:meth:`telegram.ext.Updater.start_webhook`, :meth:`telegram.ext.Updater.stop`,
:meth:`run_polling`, :wiki:`Webhooks`
:wiki:`Webhooks`
Args:
listen (:obj:`str`, optional): IP-Address to listen on. Defaults to

View file

@ -473,6 +473,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
.. include:: inclusions/pool_size_tip.rst
.. seealso:: :meth:`get_updates_connection_pool_size`
Args:
connection_pool_size (:obj:`int`): The size of the connection pool.
@ -487,6 +489,9 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
"""Sets the proxy for the :paramref:`~telegram.request.HTTPXRequest.proxy_url`
parameter of :attr:`telegram.Bot.request`. Defaults to :obj:`None`.
.. seealso:: :meth:`get_updates_proxy_url`
Args:
proxy_url (:obj:`str`): The URL to the proxy server. See
:paramref:`telegram.request.HTTPXRequest.proxy_url` for more information.
@ -503,6 +508,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
:paramref:`~telegram.request.HTTPXRequest.connect_timeout` parameter of
:attr:`telegram.Bot.request`. Defaults to ``5.0``.
.. seealso:: :meth:`get_updates_connect_timeout`
Args:
connect_timeout (:obj:`float`): See
:paramref:`telegram.request.HTTPXRequest.connect_timeout` for more information.
@ -519,6 +526,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
:paramref:`~telegram.request.HTTPXRequest.read_timeout` parameter of
:attr:`telegram.Bot.request`. Defaults to ``5.0``.
.. seealso:: :meth:`get_updates_read_timeout`
Args:
read_timeout (:obj:`float`): See
:paramref:`telegram.request.HTTPXRequest.read_timeout` for more information.
@ -535,6 +544,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
:paramref:`~telegram.request.HTTPXRequest.write_timeout` parameter of
:attr:`telegram.Bot.request`. Defaults to ``5.0``.
.. seealso:: :meth:`get_updates_write_timeout`
Args:
write_timeout (:obj:`float`): See
:paramref:`telegram.request.HTTPXRequest.write_timeout` for more information.
@ -553,6 +564,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
.. include:: inclusions/pool_size_tip.rst
.. seealso:: :meth:`get_updates_pool_timeout`
Args:
pool_timeout (:obj:`float`): See
:paramref:`telegram.request.HTTPXRequest.pool_timeout` for more information.
@ -629,6 +642,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
:paramref:`telegram.request.HTTPXRequest.connection_pool_size` parameter which is used
for the :meth:`telegram.Bot.get_updates` request. Defaults to ``1``.
.. seealso:: :meth:`connection_pool_size`
Args:
get_updates_connection_pool_size (:obj:`int`): The size of the connection pool.
@ -643,6 +658,9 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
"""Sets the proxy for the :paramref:`telegram.request.HTTPXRequest.proxy_url`
parameter which is used for :meth:`telegram.Bot.get_updates`. Defaults to :obj:`None`.
.. seealso:: :meth:`proxy_url`
Args:
get_updates_proxy_url (:obj:`str`): The URL to the proxy server. See
:paramref:`telegram.request.HTTPXRequest.proxy_url` for more information.
@ -661,6 +679,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
:paramref:`telegram.request.HTTPXRequest.connect_timeout` parameter which is used for
the :meth:`telegram.Bot.get_updates` request. Defaults to ``5.0``.
.. seealso:: :meth:`connect_timeout`
Args:
get_updates_connect_timeout (:obj:`float`): See
:paramref:`telegram.request.HTTPXRequest.connect_timeout` for more information.
@ -679,6 +699,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
:paramref:`telegram.request.HTTPXRequest.read_timeout` parameter which is used for the
:meth:`telegram.Bot.get_updates` request. Defaults to ``5.0``.
.. seealso:: :meth:`read_timeout`
Args:
get_updates_read_timeout (:obj:`float`): See
:paramref:`telegram.request.HTTPXRequest.read_timeout` for more information.
@ -697,6 +719,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
:paramref:`telegram.request.HTTPXRequest.write_timeout` parameter which is used for
the :meth:`telegram.Bot.get_updates` request. Defaults to ``5.0``.
.. seealso:: :meth:`write_timeout`
Args:
get_updates_write_timeout (:obj:`float`): See
:paramref:`telegram.request.HTTPXRequest.write_timeout` for more information.
@ -715,6 +739,8 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
:paramref:`~telegram.request.HTTPXRequest.pool_timeout` parameter which is used for the
:meth:`telegram.Bot.get_updates` request. Defaults to ``1.0``.
.. seealso:: :meth:`pool_timeout`
Args:
get_updates_pool_timeout (:obj:`float`): See
:paramref:`telegram.request.HTTPXRequest.pool_timeout` for more information.
@ -1099,6 +1125,9 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
application = Application.builder().token("TOKEN").post_init(post_init).build()
Note:
|post_methods_note|
.. seealso:: :meth:`post_stop`, :meth:`post_shutdown`
Args:
@ -1137,6 +1166,9 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
.post_shutdown(post_shutdown)
.build()
Note:
|post_methods_note|
.. seealso:: :meth:`post_init`, :meth:`post_stop`
Args:
@ -1177,6 +1209,9 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
.post_stop(post_stop)
.build()
Note:
|post_methods_note|
.. seealso:: :meth:`post_init`, :meth:`post_shutdown`
Args:

View file

@ -34,7 +34,7 @@ RT = TypeVar("RT")
class CallbackQueryHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram
"""Handler class to handle Telegram
:attr:`callback queries <telegram.Update.callback_query>`. Optionally based on a regex.
Read the documentation of the :mod:`re` module for more information.

View file

@ -28,7 +28,7 @@ from telegram.ext._utils.types import CCT, HandlerCallback
class ChatJoinRequestHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram updates that contain
"""Handler class to handle Telegram updates that contain
:attr:`telegram.Update.chat_join_request`.
Note:

View file

@ -29,7 +29,7 @@ RT = TypeVar("RT")
class ChatMemberHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram updates that contain a chat member update.
"""Handler class to handle Telegram updates that contain a chat member update.
Warning:
When setting :paramref:`block` to :obj:`False`, you cannot rely on adding custom

View file

@ -33,7 +33,7 @@ if TYPE_CHECKING:
class ChosenInlineResultHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram updates that contain
"""Handler class to handle Telegram updates that contain
:attr:`telegram.Update.chosen_inline_result`.
Warning:

View file

@ -34,7 +34,7 @@ RT = TypeVar("RT")
class CommandHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram commands.
"""Handler class to handle Telegram commands.
Commands are Telegram messages that start with ``/``, optionally followed by an ``@`` and the
bot's name and/or some additional text. The handler will add a :obj:`list` to the
@ -104,7 +104,7 @@ class CommandHandler(BaseHandler[Update, CCT]):
commands (FrozenSet[:obj:`str`]): The set of commands this handler should listen for.
callback (:term:`coroutine function`): The callback function for this handler.
filters (:class:`telegram.ext.filters.BaseFilter`): Optional. Only allow updates with these
Filters.
filters.
block (:obj:`bool`): Determines whether the return value of the callback should be
awaited before processing the next handler in
:meth:`telegram.ext.Application.process_update`.

View file

@ -33,7 +33,7 @@ RT = TypeVar("RT")
class MessageHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram messages. They might contain text, media or status
"""Handler class to handle Telegram messages. They might contain text, media or status
updates.
Warning:

View file

@ -25,7 +25,7 @@ from telegram.ext._utils.types import CCT
class PollAnswerHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram updates that contain a
"""Handler class to handle Telegram updates that contain a
:attr:`poll answer <telegram.Update.poll_answer>`.
Warning:

View file

@ -25,7 +25,7 @@ from telegram.ext._utils.types import CCT
class PollHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram updates that contain a
"""Handler class to handle Telegram updates that contain a
:attr:`poll <telegram.Update.poll>`.
Warning:

View file

@ -25,7 +25,7 @@ from telegram.ext._utils.types import CCT
class PreCheckoutQueryHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram :attr:`telegram.Update.pre_checkout_query`.
"""Handler class to handle Telegram :attr:`telegram.Update.pre_checkout_query`.
Warning:
When setting :paramref:`block` to :obj:`False`, you cannot rely on adding custom

View file

@ -34,7 +34,7 @@ RT = TypeVar("RT")
class PrefixHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle custom prefix commands.
"""Handler class to handle custom prefix commands.
This is an intermediate handler between :class:`MessageHandler` and :class:`CommandHandler`.
It supports configurable commands with the same options as :class:`CommandHandler`. It will

View file

@ -25,7 +25,7 @@ from telegram.ext._utils.types import CCT
class ShippingQueryHandler(BaseHandler[Update, CCT]):
"""BaseHandler class to handle Telegram :attr:`telegram.Update.shipping_query`.
"""Handler class to handle Telegram :attr:`telegram.Update.shipping_query`.
Warning:
When setting :paramref:`block` to :obj:`False`, you cannot rely on adding custom

View file

@ -30,7 +30,7 @@ if TYPE_CHECKING:
class StringCommandHandler(BaseHandler[str, CCT]):
"""BaseHandler class to handle string commands. Commands are string updates that start with
"""Handler class to handle string commands. Commands are string updates that start with
``/``. The handler will add a :obj:`list` to the
:class:`CallbackContext` named :attr:`CallbackContext.args`. It will contain a list of strings,
which is the text following the command split on single whitespace characters.

View file

@ -33,7 +33,7 @@ RT = TypeVar("RT")
class StringRegexHandler(BaseHandler[str, CCT]):
"""BaseHandler class to handle string updates based on a regex which checks the update content.
"""Handler class to handle string updates based on a regex which checks the update content.
Read the documentation of the :mod:`re` module for more information. The :func:`re.match`
function is used to determine if an update should be handled by this handler.

View file

@ -30,7 +30,7 @@ UT = TypeVar("UT")
class TypeHandler(BaseHandler[UT, CCT]):
"""BaseHandler class to handle updates of custom types.
"""Handler class to handle updates of custom types.
Warning:
When setting :paramref:`block` to :obj:`False`, you cannot rely on adding custom