Refactoring and write doc's for Bot class. Split bot to 2 classes

This commit is contained in:
Alex Root Junior 2017-06-04 11:10:22 +03:00
parent efad13156e
commit ba1c473f0c
7 changed files with 1021 additions and 192 deletions

9
docs/source/api.rst Normal file
View file

@ -0,0 +1,9 @@
API Reference
=============
For detailed information about parameters read the official `Telegram Bot API reference <https://core.telegram.org/bots/api>`_
.. automodule:: aiogram.bot
:members:
:show-inheritance:

View file

@ -17,9 +17,11 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
import aiogram
# -- General configuration ------------------------------------------------
@ -31,8 +33,12 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.todo',
'sphinx.ext.viewcode']
extensions = [
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinx.ext.autodoc',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['templates']
@ -56,9 +62,9 @@ author = 'Illemius / Alex Root Junior'
# built documents.
#
# The short X.Y version.
version = '0.2'
version = '{}.{}'.format(aiogram.major_version, aiogram.minor_version)
# The full version, including alpha/beta/rc tags.
release = '0.2b1'
release = aiogram.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

12
docs/source/features.rst Normal file
View file

@ -0,0 +1,12 @@
Features
========
Dispatcher
----------
.. automodule:: aiogram.dispatcher
:members:
:show-inheritance:
Markdown
--------

View file

@ -8,6 +8,31 @@ Welcome to aiogram's documentation!
Asynchonyously Python framework for `Telegram Bot API <https://core.telegram.org/bots/api>`_
.. image:: https://img.shields.io/pypi/v/aiogram.svg
:target: https://pypi.python.org/pypi/aiogram
:alt: PyPi Package Version
.. image:: https://img.shields.io/pypi/status/aiogram.svg
:target: https://pypi.python.org/pypi/aiogram
:alt: PyPi status
.. image:: https://img.shields.io/pypi/pyversions/aiogram.svg
:target: https://pypi.python.org/pypi/aiogram
:alt: Supported python versions
.. image:: https://readthedocs.org/projects/aiogram/badge/?version=latest
:target: http://aiogram.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://img.shields.io/bitbucket/issues/illemius/aiogram.svg
:target: https://bitbucket.org/illemius/aiogram/issues
:alt: Bitbucket issues
.. image:: https://img.shields.io/pypi/l/aiogram.svg
:target: https://opensource.org/licenses/MIT
:alt: MIT License
Features
--------
@ -28,7 +53,8 @@ Contents
.. toctree::
install
quick_start
api
features

View file

@ -1,3 +1,65 @@
Quick start
===========
Simple template
---------------
.. code-block:: python3
import asyncio
from aiogram import Bot
loop = asyncio.get_event_loop()
bot = Bot('TOKEN', loop)
async def main():
bot_info = await bot.get_me()
print(bot_info.username)
if __name__ == '__main__':
try:
loop.run_until_complete(main())
except KeyboardInterrupt:
loop.stop()
Manual
------
First you need to get event loop from asyncio
.. code-block:: python3
import asyncio
loop = asyncio.get_event_loop()
Then create bot instance, if you have bot token.
Token you can get from `@BotFather <https://t.me/BotFather>`_
.. code-block:: python3
from aiogram import Bot
bot = Bot('TOKEN', loop)
And then you can use Dispather module:
.. code-block:: python3
from aiogram.dispather import Dispatcher
dp = Dispatcher(bot)
Dispatcher cah handler updates from telegram bot API.
It have **dp.start_pooling()** method.