Skip to content

Commit 944b672

Browse files
committed
Docs revamp. Part 4
1 parent a5e4257 commit 944b672

35 files changed

Lines changed: 398 additions & 275 deletions

compiler/docs/template/page.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{title}
22
{title_markup}
33

4-
.. autoclass:: {full_class_path}
4+
.. autoclass:: {full_class_path}()
55
:members:

docs/source/api/bound-methods.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
Bound Methods
2+
=============
3+
4+
Some Pyrogram types define what are called bound methods. Bound methods are functions attached to a class which are
5+
accessed via an instance of that class. They make it even easier to call specific methods by automatically inferring
6+
some of the required arguments.
7+
8+
.. code-block:: python
9+
:emphasize-lines: 8
10+
11+
from pyrogram import Client
12+
13+
app = Client("my_account")
14+
15+
16+
@app.on_message()
17+
def hello(client, message)
18+
message.reply("hi")
19+
20+
21+
app.run()
22+
23+
.. currentmodule:: pyrogram
24+
25+
- Message_
26+
- CallbackQuery_
27+
- InlineQuery_
28+
29+
.. _Message:
30+
31+
Message
32+
-------
33+
34+
- :meth:`Message.click()`
35+
- :meth:`Message.delete()`
36+
- :meth:`Message.download()`
37+
- :meth:`Message.edit()`
38+
- :meth:`Message.edit_caption()`
39+
- :meth:`Message.edit_media()`
40+
- :meth:`Message.edit_reply_markup()`
41+
- :meth:`Message.forward()`
42+
- :meth:`Message.pin()`
43+
- :meth:`Message.reply()`
44+
- :meth:`Message.reply_animation()`
45+
- :meth:`Message.reply_audio()`
46+
- :meth:`Message.reply_cached_media()`
47+
- :meth:`Message.reply_chat_action()`
48+
- :meth:`Message.reply_contact()`
49+
- :meth:`Message.reply_document()`
50+
- :meth:`Message.reply_game()`
51+
- :meth:`Message.reply_inline_bot_result()`
52+
- :meth:`Message.reply_location()`
53+
- :meth:`Message.reply_media_group()`
54+
- :meth:`Message.reply_photo()`
55+
- :meth:`Message.reply_poll()`
56+
- :meth:`Message.reply_sticker()`
57+
- :meth:`Message.reply_venue()`
58+
- :meth:`Message.reply_video()`
59+
- :meth:`Message.reply_video_note()`
60+
- :meth:`Message.reply_voice()`
61+
62+
.. automethod:: Message.click()
63+
.. automethod:: Message.delete()
64+
.. automethod:: Message.download()
65+
.. automethod:: Message.edit()
66+
.. automethod:: Message.edit_caption()
67+
.. automethod:: Message.edit_media()
68+
.. automethod:: Message.edit_reply_markup()
69+
.. automethod:: Message.forward()
70+
.. automethod:: Message.pin()
71+
.. automethod:: Message.reply()
72+
.. automethod:: Message.reply_animation()
73+
.. automethod:: Message.reply_audio()
74+
.. automethod:: Message.reply_cached_media()
75+
.. automethod:: Message.reply_chat_action()
76+
.. automethod:: Message.reply_contact()
77+
.. automethod:: Message.reply_document()
78+
.. automethod:: Message.reply_game()
79+
.. automethod:: Message.reply_inline_bot_result()
80+
.. automethod:: Message.reply_location()
81+
.. automethod:: Message.reply_media_group()
82+
.. automethod:: Message.reply_photo()
83+
.. automethod:: Message.reply_poll()
84+
.. automethod:: Message.reply_sticker()
85+
.. automethod:: Message.reply_venue()
86+
.. automethod:: Message.reply_video()
87+
.. automethod:: Message.reply_video_note()
88+
.. automethod:: Message.reply_voice()
89+
90+
.. _CallbackQuery:
91+
92+
CallbackQuery
93+
-------------
94+
95+
.. automethod:: CallbackQuery.answer()
96+
97+
.. _InlineQuery:
98+
99+
InlineQuery
100+
-----------
101+
102+
.. automethod:: InlineQuery.answer()

docs/source/api/client.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
Pyrogram Client
22
===============
33

4-
The :class:`Client <pyrogram.Client>` is the main class. It exposes easy-to-use methods that are named
5-
after the well established Telegram Bot API methods, thus offering a familiar look to Bot developers.
4+
This class exposes high-level methods for an easy access to the API.
5+
6+
.. code-block:: python
7+
:emphasize-lines: 1-3
8+
9+
from pyrogram import Client
10+
11+
app = Client("my_account")
12+
13+
with app:
14+
app.send_message("me", "Hi!")
615
716
.. autoclass:: pyrogram.Client()

docs/source/api/decorators.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
Decorators
22
==========
33

4-
While still being methods bound to the :obj:`Client` class, decorators are of a special kind and thus deserve a
4+
While still being methods bound to the :obj:`Client <pyrogram.Client>` class, decorators are of a special kind and thus deserve a
55
dedicated page.
66

77
Decorators are able to register callback functions for handling updates in a much easier and cleaner way compared to
88
`Handlers <Handlers.html>`_; they do so by instantiating the correct handler and calling
99
:meth:`add_handler() <pyrogram.Client.add_handler>`, automatically. All you need to do is adding the decorators on top
1010
of your functions.
1111

12-
**Example:**
13-
1412
.. code-block:: python
13+
:emphasize-lines: 6
1514
1615
from pyrogram import Client
1716
18-
app = Client(...)
17+
app = Client("my_account")
1918
2019
2120
@app.on_message()

docs/source/api/errors.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,26 @@ All Pyrogram API errors live inside the ``errors`` sub-package: ``pyrogram.error
55
The errors ids listed here are shown as *UPPER_SNAKE_CASE*, but the actual exception names to import from Pyrogram
66
follow the usual *PascalCase* convention.
77

8-
**Example**:
9-
108
.. code-block:: python
9+
:emphasize-lines: 1, 5
1110
12-
from pyrogram.errors import InternalServerError
11+
from pyrogram.errors import FloodWait
1312
1413
try:
1514
...
16-
except FloodWait:
15+
except FloodWait as e:
1716
...
1817
19-
303 - See Other
20-
---------------
18+
303 - SeeOther
19+
--------------
2120

2221
.. csv-table::
2322
:file: ../../../compiler/error/source/303_SEE_OTHER.tsv
2423
:delim: tab
2524
:header-rows: 1
2625

27-
400 - Bad Request
28-
-----------------
26+
400 - BadRequest
27+
----------------
2928

3029
.. csv-table::
3130
:file: ../../../compiler/error/source/400_BAD_REQUEST.tsv
@@ -48,8 +47,8 @@ follow the usual *PascalCase* convention.
4847
:delim: tab
4948
:header-rows: 1
5049

51-
406 - Not Acceptable
52-
--------------------
50+
406 - NotAcceptable
51+
-------------------
5352

5453
.. csv-table::
5554
:file: ../../../compiler/error/source/406_NOT_ACCEPTABLE.tsv
@@ -64,8 +63,8 @@ follow the usual *PascalCase* convention.
6463
:delim: tab
6564
:header-rows: 1
6665

67-
500 - Internal Server Error
68-
---------------------------
66+
500 - InternalServerError
67+
-------------------------
6968

7069
.. csv-table::
7170
:file: ../../../compiler/error/source/500_INTERNAL_SERVER_ERROR.tsv

docs/source/api/handlers.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ For a much more convenient way of registering callback functions have a look at
77
In case you decided to manually create an handler, use :meth:`add_handler() <pyrogram.Client.add_handler>` to register
88
it.
99

10-
**Example:**
11-
1210
.. code-block:: python
11+
:emphasize-lines: 1, 10
1312
1413
from pyrogram import Client, MessageHandler
1514
16-
app = Client(...)
15+
app = Client("my_account")
1716
1817
1918
def dump(client, message):
@@ -34,6 +33,7 @@ it.
3433
CallbackQueryHandler
3534
InlineQueryHandler
3635
UserStatusHandler
36+
PollHandler
3737
DisconnectHandler
3838
RawUpdateHandler
3939

@@ -52,6 +52,9 @@ it.
5252
.. autoclass:: UserStatusHandler()
5353
:members:
5454

55+
.. autoclass:: PollHandler()
56+
:members:
57+
5558
.. autoclass:: DisconnectHandler()
5659
:members:
5760

docs/source/api/methods.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ Available Methods
33

44
All Pyrogram methods listed here are bound to a :obj:`Client <pyrogram.Client>` instance.
55

6-
**Example:**
7-
86
.. code-block:: python
7+
:emphasize-lines: 6
98
109
from pyrogram import Client
1110
12-
app = Client(...)
11+
app = Client("my_account")
1312
1413
with app:
1514
app.send_message("haskell", "hi")

0 commit comments

Comments
 (0)