mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add Bot API parser and code-generator
This commit is contained in:
parent
5e9d4e55d9
commit
af2573dbee
15 changed files with 3242 additions and 1 deletions
12
generator/templates/type.py.jinja2
Normal file
12
generator/templates/type.py.jinja2
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
class {{ entity.python_name }}(pydantic.BaseModel):
|
||||
"""
|
||||
{{ entity.description|indent(width=4) }}
|
||||
|
||||
Source: https://core.telegram.org/bots/api#{{ entity.anchor }}
|
||||
"""
|
||||
{% for annotation in entity.annotations %}
|
||||
{{ annotation.python_argument }}
|
||||
"""{{ annotation.description|indent(width=4) }}"""
|
||||
{% else %}
|
||||
pass
|
||||
{% endfor %}
|
||||
20
generator/templates/types.py.jinja2
Normal file
20
generator/templates/types.py.jinja2
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
"""
|
||||
!!! DO NOT EDIT THIS FILE !!!
|
||||
This file is autogenerated from Docs of Telegram Bot API at {{ timestamp }}
|
||||
"""
|
||||
import typing
|
||||
|
||||
import pydantic
|
||||
|
||||
from aiogram import types
|
||||
|
||||
__all__ = [
|
||||
{% for group in groups %}{% for entity in group.childs %}{% if entity.is_type %}
|
||||
"{{ entity.python_name }}",
|
||||
{% endif %}{% endfor %}{% endfor %}
|
||||
]
|
||||
|
||||
|
||||
{% for group in groups %}
|
||||
{% include 'types_group.py.jinja2' %}
|
||||
{% endfor %}
|
||||
10
generator/templates/types_group.py.jinja2
Normal file
10
generator/templates/types_group.py.jinja2
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# %% Region: '{{ group.title }}'
|
||||
"""{% if group.description %}
|
||||
{{ group.description }}
|
||||
{% endif %}
|
||||
link: https://core.telegram.org/bots/api#{{ group.anchor }}
|
||||
"""
|
||||
{% for entity in group.childs %}{% if entity.is_type %}
|
||||
{% include 'type.py.jinja2' %}
|
||||
{% endif %}{% endfor %}
|
||||
# %% End of region '{{ group.title }}'
|
||||
Loading…
Add table
Add a link
Reference in a new issue