Small changes in documentation

This commit is contained in:
Alex Root Junior 2021-05-12 23:00:12 +03:00
parent 9f902ef232
commit 74db2c47e6
8 changed files with 88 additions and 52 deletions

View file

@ -2,7 +2,7 @@
[![MIT License](https://img.shields.io/pypi/l/aiogram.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![Supported python versions](https://img.shields.io/pypi/pyversions/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram)
[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-4.6-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-5.2-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![PyPi Package Version](https://img.shields.io/pypi/v/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram)
[![PyPi status](https://img.shields.io/pypi/status/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram)
[![Downloads](https://img.shields.io/pypi/dm/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram)

View file

@ -5,6 +5,10 @@ T = TypeVar("T")
class BaseMiddleware(ABC, Generic[T]):
"""
Generic middleware class
"""
@abstractmethod
async def __call__(
self,
@ -12,4 +16,12 @@ class BaseMiddleware(ABC, Generic[T]):
event: T,
data: Dict[str, Any],
) -> Any: # pragma: no cover
"""
Execute middleware
:param handler: Wrapped handler in middlewares chain
:param event: Incoming event (Subclass of :class:`aiogram.types.base.TelegramObject`)
:param data: Contextual data. Will be mapped to handler arguments
:return: :class:`Any`
"""
pass

View file

@ -23,3 +23,4 @@ Dispatcher is subclass of router and should be always is root router.
class_based_handlers/index
filters/index
filters/magic_filters
middlewares

View file

@ -13,7 +13,7 @@ aiogram
:target: https://pypi.python.org/pypi/aiogram
:alt: Supported python versions
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-4.9-blue.svg?logo=telegram
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.2-blue.svg?logo=telegram
:target: https://core.telegram.org/bots/api
:alt: Telegram Bot API

View file

@ -12,53 +12,31 @@ Using PIP
pip install -U aiogram
Using AUR
---------
Using poetry
------------
*aiogram* 2.x is also available in Arch Linux Repository, so you can install this framework
on any Arch-based distribution like Arch Linux, Antergos, Manjaro, etc.
To do this, just use pacman to install the *python-aiogram* package:
.. code-block:: bash
poetry add aiogram
Using Pipenv
------------
.. code-block:: bash
pipenv install aiogram
Using poetry
------------
.. code-block:: bash
poetry add aiogram
Using Pacman
------------
*aiogram* is also available in Arch Linux Repository, so you can install this framework on any
Arch-based distribution like Arch Linux, Antergos, Manjaro, etc. To do this, just use pacman
to install the `python-aiogram <https://archlinux.org/packages/community/any/python-aiogram/>`_ package:
.. code-block:: bash
pacman -S python-aiogram
$ pacman -S python-aiogram
Development build (3.x)
=======================
From private PyPi index
From test PyPi index
-----------------------
On every push to the `dev-3.x` branch GitHub Actions build the package and publish
to the `2038.host <https://aiogram.2038.io/simple>`_ server with seems like official PyPi files structure.
That's mean you can always install latest (may be unstable) build via next command:
.. code-block:: bash
pip install --extra-index-url https://dev-docs.aiogram.dev/simple --pre aiogram
pip install -U --extra-index-url https://test.pypi.org/simple/ --pre aiogram
From GitHub
-----------
In this repository available only last success build. All previous builds is always removes
before uploading new one. Also before building this package all tests is also pass.
.. code-block:: bash
pip install https://github.com/aiogram/aiogram/archive/refs/heads/dev-3.x.zip

View file

@ -6,6 +6,7 @@ import toml
BASE_PATTERN = r'({variable} = ")[a-z0-9.+]+(")'
PACKAGE_VERSION = re.compile(BASE_PATTERN.format(variable="__version__"))
API_VERSION = re.compile(BASE_PATTERN.format(variable="__api_version__"))
API_VERSION_BADGE = re.compile(r"(API-)[\d.]+(-blue\.svg)")
STAGE_MAPPING = {
"alpha": "a",
@ -37,7 +38,8 @@ def get_telegram_api_version() -> str:
def replace_line(content: str, pattern: re.Pattern, new_value: str) -> str:
return pattern.sub(f"\\g<1>{new_value}\\g<2>", content)
result = pattern.sub(f"\\g<1>{new_value}\\g<2>", content)
return result
def write_package_meta(package_version: str, api_version: str) -> None:
@ -51,6 +53,22 @@ def write_package_meta(package_version: str, api_version: str) -> None:
path.write_text(content)
def write_readme(package_version: str, api_version: str) -> None:
path = Path.cwd() / "README.md"
content = path.read_text()
content = replace_line(content, API_VERSION_BADGE, api_version)
print(f"Write {path}")
path.write_text(content)
def write_docs_index(package_version: str, api_version: str) -> None:
path = Path.cwd() / "docs2" / "index.rst"
content = path.read_text()
content = replace_line(content, API_VERSION_BADGE, api_version)
print(f"Write {path}")
path.write_text(content)
def write_docs_meta(package_version: str, api_version: str) -> None:
api_meta = Path.cwd() / "docs" / "_api_version.md"
package_meta = Path.cwd() / "docs" / "_package_version.md"
@ -69,6 +87,8 @@ def main():
print(f"Telegram Bot API version: {api_version}")
write_package_meta(package_version=package_version, api_version=api_version)
write_docs_meta(package_version=package_version, api_version=api_version)
write_readme(package_version=package_version, api_version=api_version)
write_docs_index(package_version=package_version, api_version=api_version)
if __name__ == "__main__":

View file

@ -1,9 +1,10 @@
import datetime
from typing import Any, Dict, Type, Union, Optional
from typing import Any, Dict, Optional, Type, Union
import pytest
from aiogram.methods import (
CopyMessage,
SendAnimation,
SendAudio,
SendContact,
@ -21,7 +22,6 @@ from aiogram.methods import (
SendVideo,
SendVideoNote,
SendVoice,
CopyMessage,
TelegramMethod,
)
from aiogram.types import (
@ -35,6 +35,7 @@ from aiogram.types import (
Game,
Invoice,
Location,
MessageAutoDeleteTimerChanged,
PassportData,
PhotoSize,
Poll,
@ -46,10 +47,9 @@ from aiogram.types import (
Video,
VideoNote,
Voice,
MessageAutoDeleteTimerChanged,
VoiceChatStarted,
VoiceChatEnded,
VoiceChatParticipantsInvited,
VoiceChatStarted,
)
from aiogram.types.message import ContentType, Message
@ -71,7 +71,11 @@ TEST_MESSAGE_ANIMATION = Message(
message_id=42,
date=datetime.datetime.now(),
animation=Animation(
file_id="file id", file_unique_id="file id", width=42, height=42, duration=0,
file_id="file id",
file_unique_id="file id",
width=42,
height=42,
duration=0,
),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
@ -106,7 +110,11 @@ TEST_MESSAGE_STICKER = Message(
message_id=42,
date=datetime.datetime.now(),
sticker=Sticker(
file_id="file id", file_unique_id="file id", width=42, height=42, is_animated=False,
file_id="file id",
file_unique_id="file id",
width=42,
height=42,
is_animated=False,
),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
@ -114,7 +122,13 @@ TEST_MESSAGE_STICKER = Message(
TEST_MESSAGE_VIDEO = Message(
message_id=42,
date=datetime.datetime.now(),
video=Video(file_id="file id", file_unique_id="file id", width=42, height=42, duration=0,),
video=Video(
file_id="file id",
file_unique_id="file id",
width=42,
height=42,
duration=0,
),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
)
@ -264,7 +278,8 @@ TEST_MESSAGE_PASSPORT_DATA = Message(
message_id=42,
date=datetime.datetime.now(),
passport_data=PassportData(
data=[], credentials=EncryptedCredentials(data="test", hash="test", secret="test"),
data=[],
credentials=EncryptedCredentials(data="test", hash="test", secret="test"),
),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
@ -275,7 +290,10 @@ TEST_MESSAGE_POLL = Message(
poll=Poll(
id="QA",
question="Q",
options=[PollOption(text="A", voter_count=0), PollOption(text="B", voter_count=0),],
options=[
PollOption(text="A", voter_count=0),
PollOption(text="B", voter_count=0),
],
is_closed=False,
is_anonymous=False,
type="quiz",
@ -410,7 +428,12 @@ class TestMessage:
["sticker", dict(sticker="sticker"), SendSticker],
[
"venue",
dict(latitude=0.42, longitude=0.42, title="title", address="address",),
dict(
latitude=0.42,
longitude=0.42,
title="title",
address="address",
),
SendVenue,
],
["video", dict(video="video"), SendVideo],
@ -513,7 +536,9 @@ class TestMessage:
],
)
def test_send_copy(
self, message: Message, expected_method: Optional[Type[TelegramMethod]],
self,
message: Message,
expected_method: Optional[Type[TelegramMethod]],
):
if expected_method is None:
with pytest.raises(TypeError, match="This type of message can't be copied."):

View file

@ -15,6 +15,8 @@ from aiogram.methods import GetMe, GetUpdates, SendMessage
from aiogram.types import (
CallbackQuery,
Chat,
ChatMember,
ChatMemberUpdated,
ChosenInlineResult,
InlineQuery,
Message,
@ -26,8 +28,6 @@ from aiogram.types import (
ShippingQuery,
Update,
User,
ChatMemberUpdated,
ChatMember,
)
from tests.mocked_bot import MockedBot