Skip to content

Commit bc4ccf2

Browse files
HitaloMalissonlauffer
authored andcommitted
docs: update installation instructions and enhance quick start guide
1 parent 51378eb commit bc4ccf2

File tree

6 files changed

+162
-84
lines changed

6 files changed

+162
-84
lines changed

compiler/docs/template/methods.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ Authorization
151151

152152
{authorization}
153153

154+
Phone
155+
-----
156+
157+
.. autosummary::
158+
:nosignatures:
159+
160+
{phone}
161+
162+
.. toctree::
163+
:hidden:
164+
165+
{phone}
166+
154167
Advanced
155168
--------
156169

docs/source/conf.py

Lines changed: 96 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
1+
# Hydrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
3+
#
4+
# This file is part of Hydrogram.
5+
#
6+
# Hydrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Hydrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Hydrogram. If not, see <http://www.gnu.org/licenses/>.
18+
119
import datetime
220
import sys
321
from pathlib import Path
422

23+
# Setup path for imports
524
docs_dir = Path(__file__).parent.parent
625
sys.path.insert(0, docs_dir.resolve().as_posix())
726

827
import hydrogram # noqa: E402
928

29+
# Project information
1030
project = "Hydrogram"
1131
author = "Hydrogram"
1232
copyright = f"{datetime.date.today().year}, {author}"
1333
release = hydrogram.__version__
1434

35+
# Sphinx extensions
1536
extensions = [
1637
"sphinx.ext.autodoc",
1738
"sphinx.ext.viewcode",
@@ -22,44 +43,104 @@
2243
"sphinxcontrib.towncrier.ext",
2344
]
2445

46+
# Intersphinx mapping for external documentation
2547
intersphinx_mapping = {
2648
"python": ("https://docs.python.org/3", None),
2749
"aiosqlite": ("https://aiosqlite.omnilib.dev/en/stable/", None),
2850
}
2951

52+
# Basic configuration
53+
master_doc = "index"
54+
source_suffix = ".rst"
55+
pygments_style = "friendly"
56+
57+
# Documentation generation settings
58+
autodoc_member_order = "bysource"
59+
autodoc_typehints = "none"
3060
html_use_modindex = False
3161
html_use_index = False
3262

63+
# Napoleon settings (for Google-style docstrings)
3364
napoleon_use_rtype = False
3465
napoleon_use_param = False
3566

36-
master_doc = "index"
37-
source_suffix = ".rst"
38-
autodoc_member_order = "bysource"
39-
autodoc_typehints = "none"
40-
67+
# Towncrier settings
4168
towncrier_draft_autoversion_mode = "draft"
4269
towncrier_draft_include_empty = True
4370
towncrier_draft_working_directory = Path(__file__).parent.parent.parent
4471

45-
pygments_style = "friendly"
46-
72+
# HTML theme settings
4773
html_theme = "furo"
4874
html_title = f"{project} v{release} Documentation"
4975
html_last_updated_fmt = (
5076
f"{datetime.datetime.now(tz=datetime.UTC).strftime('%d/%m/%Y, %H:%M:%S')} UTC"
5177
)
52-
5378
html_copy_source = False
54-
5579
html_static_path = ["_static"]
5680
html_css_files = [
5781
"css/all.min.css",
5882
"css/custom.css",
5983
]
6084

85+
# Icons for footer (from https://react-icons.github.io/react-icons)
86+
TELEGRAM_ICON = (
87+
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
88+
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
89+
'<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.287 5.906c-.778.324-2.334.994'
90+
"-4.666 2.01-.378.15-.577.298-.595.442-.03.243.275.339.69.47l.175.055c.408.133."
91+
"958.288 1.243.294.26.006.549-.1.868-.32 2.179-1.471 3.304-2.214 3.374-2.23.0"
92+
"5-.012.12-.026.166.016.047.041.042.12.037.141-.03.129-1.227 1.241-1.846 1.81"
93+
"7-.193.18-.33.307-.358.336a8.154 8.154 0 0 1-.188.186c-.38.366-.664.64.015 1.08"
94+
"8.327.216.589.393.85.571.284.194.568.387.936.629.093.06.183.125.27.187.331.23"
95+
"6.63.448.997.414.214-.02.435-.22.547-.82.265-1.417.786-4.486.906-5.751a1.426 "
96+
"1.426 0 0 0-.013-.315.337.337 0 0 0-.114-.217.526.526 0 0 0-.31-.093c-.3.005-.7"
97+
'63.166-2.984 1.09z"></path></svg>'
98+
)
99+
100+
GITHUB_ICON = (
101+
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
102+
'viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 '
103+
"2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.4"
104+
"9-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23"
105+
".82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 "
106+
"0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.2"
107+
"7 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.5"
108+
"1.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 "
109+
'1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z">'
110+
"</path></svg>"
111+
)
112+
113+
WEBSITE_ICON = (
114+
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
115+
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
116+
'<path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 '
117+
"1.855-.143.268-.276.56-.395.872.705.157 1.472.257 2.282.287V1.077zM4.249 3.53"
118+
"9c.142-.384.304-.744.481-1.078a6.7 6.7 0 0 1 .597-.933A7.01 7.01 0 0 0 3.051 "
119+
"3.05c.362.184.763.349 1.198.49zM3.509 7.5c.036-1.07.188-2.087.436-3.008a9.124 "
120+
"9.124 0 0 1-1.565-.667A6.964 6.964 0 0 0 1.018 7.5h2.49zm1.4-2.741a12.344 "
121+
"12.344 0 0 0-.4 2.741H7.5V5.091c-.91-.03-1.783-.145-2.591-.332zM8.5 5.09V7.5h"
122+
"2.99a12.342 12.342 0 0 0-.399-2.741c-.808.187-1.681.301-2.591.332zM4.51 8.5c.03"
123+
"5.987.176 1.914.399 2.741A13.612 13.612 0 0 1 7.5 10.91V8.5H4.51zm3.99 0v2.409"
124+
"c.91.03 1.783.145 2.591.332.223-.827.364-1.754.4-2.741H8.5zm-3.282 3.696c.12.31"
125+
"2.252.604.395.872.552 1.035 1.218 1.65 1.887 1.855V11.91c-.81.03-1.577.13-2.28"
126+
"2.287zm.11 2.276a6.696 6.696 0 0 1-.598-.933 8.853 8.853 0 0 1-.481-1.079 8.38 "
127+
"8.38 0 0 0-1.198.49 7.01 7.01 0 0 0 2.276 1.522zm-1.383-2.964A13.36 13.36 0 0 1"
128+
" 3.508 8.5h-2.49a6.963 6.963 0 0 0 1.362 3.675c.47-.258.995-.482 1.565-.667zm"
129+
"6.728 2.964a7.009 7.009 0 0 0 2.275-1.521 8.376 8.376 0 0 0-1.197-.49 8.853 "
130+
"8.853 0 0 1-.481 1.078 6.688 6.688 0 0 1-.597.933zM8.5 11.909v3.014c.67-.204 "
131+
"1.335-.82 1.887-1.855.143-.268.276-.56.395-.872A12.63 12.63 0 0 0 8.5 11.91zm"
132+
"3.555-.401c.57.185 1.095.409 1.565.667A6.963 6.963 0 0 0 14.982 8.5h-2.49a1"
133+
"3.36 13.36 0 0 1-.437 3.008zM14.982 7.5a6.963 6.963 0 0 0-1.362-3.675c-.47.25"
134+
"8-.995.482-1.565.667.248.92.4 1.938.437 3.008h2.49zM11.27 2.461c.177.334.339.6"
135+
"94.482 1.078a8.368 8.368 0 0 0 1.196-.49 7.01 7.01 0 0 0-2.275-1.52c.218.283.4"
136+
"18.597.597.932zm-.488 1.343a7.765 7.765 0 0 0-.395-.872C9.835 1.897 9.17 1.282 "
137+
'8.5 1.077V4.09c.81-.03 1.577-.13 2.282-.287z"></path></svg>'
138+
)
139+
140+
# Theme options configuration
61141
html_theme_options = {
62142
"navigation_with_keys": True,
143+
# CSS variables
63144
"dark_css_variables": {
64145
"admonition-title-font-size": "0.95rem",
65146
"admonition-font-size": "0.92rem",
@@ -68,73 +149,27 @@
68149
"admonition-title-font-size": "0.95rem",
69150
"admonition-font-size": "0.92rem",
70151
},
152+
# Logo configuration
71153
"light_logo": "hydrogram-light.png",
72154
"dark_logo": "hydrogram-dark.png",
73-
"footer_icons": [ # all these icons are from https://react-icons.github.io/react-icons
155+
# Footer icons
156+
"footer_icons": [
74157
{
75158
"name": "Telegram Channel",
76159
"url": "https://t.me/HydrogramNews/",
77-
"html": (
78-
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
79-
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
80-
'<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.287 5.906c-.778.324-2.334.994'
81-
"-4.666 2.01-.378.15-.577.298-.595.442-.03.243.275.339.69.47l.175.055c.408.133."
82-
"958.288 1.243.294.26.006.549-.1.868-.32 2.179-1.471 3.304-2.214 3.374-2.23.0"
83-
"5-.012.12-.026.166.016.047.041.042.12.037.141-.03.129-1.227 1.241-1.846 1.81"
84-
"7-.193.18-.33.307-.358.336a8.154 8.154 0 0 1-.188.186c-.38.366-.664.64.015 1.08"
85-
"8.327.216.589.393.85.571.284.194.568.387.936.629.093.06.183.125.27.187.331.23"
86-
"6.63.448.997.414.214-.02.435-.22.547-.82.265-1.417.786-4.486.906-5.751a1.426 "
87-
"1.426 0 0 0-.013-.315.337.337 0 0 0-.114-.217.526.526 0 0 0-.31-.093c-.3.005-.7"
88-
'63.166-2.984 1.09z"></path></svg>'
89-
),
160+
"html": TELEGRAM_ICON,
90161
"class": "",
91162
},
92163
{
93164
"name": "GitHub Organization",
94165
"url": "https://github.com/hydrogram/",
95-
"html": (
96-
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
97-
'viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 '
98-
"2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.4"
99-
"9-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23"
100-
".82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 "
101-
"0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.2"
102-
"7 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.5"
103-
"1.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 "
104-
'1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z">'
105-
"</path></svg>"
106-
),
166+
"html": GITHUB_ICON,
107167
"class": "",
108168
},
109169
{
110170
"name": "Hydrogram Website",
111171
"url": "https://hydrogram.org/",
112-
"html": (
113-
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
114-
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
115-
'<path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 '
116-
"1.855-.143.268-.276.56-.395.872.705.157 1.472.257 2.282.287V1.077zM4.249 3.53"
117-
"9c.142-.384.304-.744.481-1.078a6.7 6.7 0 0 1 .597-.933A7.01 7.01 0 0 0 3.051 "
118-
"3.05c.362.184.763.349 1.198.49zM3.509 7.5c.036-1.07.188-2.087.436-3.008a9.124 "
119-
"9.124 0 0 1-1.565-.667A6.964 6.964 0 0 0 1.018 7.5h2.49zm1.4-2.741a12.344 "
120-
"12.344 0 0 0-.4 2.741H7.5V5.091c-.91-.03-1.783-.145-2.591-.332zM8.5 5.09V7.5h"
121-
"2.99a12.342 12.342 0 0 0-.399-2.741c-.808.187-1.681.301-2.591.332zM4.51 8.5c.03"
122-
"5.987.176 1.914.399 2.741A13.612 13.612 0 0 1 7.5 10.91V8.5H4.51zm3.99 0v2.409"
123-
"c.91.03 1.783.145 2.591.332.223-.827.364-1.754.4-2.741H8.5zm-3.282 3.696c.12.31"
124-
"2.252.604.395.872.552 1.035 1.218 1.65 1.887 1.855V11.91c-.81.03-1.577.13-2.28"
125-
"2.287zm.11 2.276a6.696 6.696 0 0 1-.598-.933 8.853 8.853 0 0 1-.481-1.079 8.38 "
126-
"8.38 0 0 0-1.198.49 7.01 7.01 0 0 0 2.276 1.522zm-1.383-2.964A13.36 13.36 0 0 1"
127-
" 3.508 8.5h-2.49a6.963 6.963 0 0 0 1.362 3.675c.47-.258.995-.482 1.565-.667zm"
128-
"6.728 2.964a7.009 7.009 0 0 0 2.275-1.521 8.376 8.376 0 0 0-1.197-.49 8.853 "
129-
"8.853 0 0 1-.481 1.078 6.688 6.688 0 0 1-.597.933zM8.5 11.909v3.014c.67-.204 "
130-
"1.335-.82 1.887-1.855.143-.268.276-.56.395-.872A12.63 12.63 0 0 0 8.5 11.91zm"
131-
"3.555-.401c.57.185 1.095.409 1.565.667A6.963 6.963 0 0 0 14.982 8.5h-2.49a1"
132-
"3.36 13.36 0 0 1-.437 3.008zM14.982 7.5a6.963 6.963 0 0 0-1.362-3.675c-.47.25"
133-
"8-.995.482-1.565.667.248.92.4 1.938.437 3.008h2.49zM11.27 2.461c.177.334.339.6"
134-
"94.482 1.078a8.368 8.368 0 0 0 1.196-.49 7.01 7.01 0 0 0-2.275-1.52c.218.283.4"
135-
"18.597.597.932zm-.488 1.343a7.765 7.765 0 0 0-.395-.872C9.835 1.897 9.17 1.282 "
136-
'8.5 1.077V4.09c.81-.03 1.577-.13 2.282-.287z"></path></svg>'
137-
),
172+
"html": WEBSITE_ICON,
138173
"class": "",
139174
},
140175
],

docs/source/faq/why-is-the-api-key-needed-for-bots.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Why is the API key needed for bots?
44
Requests against the official bot API endpoints are made via JSON/HTTP and are handled by an intermediate server
55
application that implements the MTProto protocol and uses its own API key to communicate with the MTProto servers.
66

7-
.. figure:: //_static/img/mtproto-vs-bot-api.png
7+
.. figure:: /_static/img/mtproto-vs-bot-api.png
88
:align: center
99

1010
Using MTProto is the only way to communicate with the actual Telegram servers, and the main API requires developers to

docs/source/intro/install.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@ Install Hydrogram
1515
1616
$ pip3 install -U hydrogram
1717
18-
- or, with :doc:`TgCrypto <../topics/speedups>` as extra requirement (recommended):
18+
- or, with :doc:`TgCrypto and uvloop <../topics/speedups>` as extra requirements (recommended for better performance):
1919

2020
.. code-block:: text
2121
22-
$ pip3 install -U hydrogram tgcrypto
22+
$ pip3 install -U "hydrogram[fast]"
2323
2424
Bleeding Edge
2525
-------------
2626

27-
You can install the development version from the git ``dev`` branch using this command:
27+
The development version from the git ``dev`` branch contains the latest features and fixes, but it
28+
may also include unfinished changes, bugs, or unstable code. Using this version can lead to unexpected
29+
behavior, or compatibility issues. It is recommended only for advanced users who want to
30+
test new features and are comfortable troubleshooting problems.
31+
32+
You can install the development version using this command:
2833

2934
.. code-block:: text
3035

docs/source/intro/quickstart.rst

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,79 @@
11
Quick Start
22
===========
33

4-
The next few steps serve as a quick start to see Hydrogram in action as fast as possible.
4+
Welcome to Hydrogram! This guide will help you set up and run your first Telegram bot or client application in minutes.
55

6-
Get Hydrogram Real Fast
7-
-----------------------
6+
What is Hydrogram?
7+
------------------
88

9-
1. Install Hydrogram with ``pip3 install -U hydrogram``.
9+
Hydrogram is a modern, elegant Python framework that allows you to interact with the Telegram API. With Hydrogram, you can:
1010

11-
2. Obtain the API key by following Telegram's instructions and rules at https://core.telegram.org/api/obtaining_api_id.
11+
- Create Telegram bots with advanced features
12+
- Build user clients (userbot)
13+
- Access and manage your Telegram account programmatically
14+
- Automate Telegram-related tasks
15+
- Handle updates and respond to messages
16+
17+
Let's get started with a simple example:
18+
19+
Getting Started
20+
---------------
21+
22+
1. **Install Hydrogram** with ``pip3 install -U hydrogram``.
23+
24+
2. **Obtain your API credentials** from Telegram:
25+
26+
- Go to https://my.telegram.org/apps and log in with your phone number
27+
- Create a new application to get your ``api_id`` and ``api_hash``
1228

1329
.. note::
1430

15-
Make sure you understand and abide to the rules for third-party clients and libraries explained in the link above.
31+
Make sure you understand and abide by Telegram's terms of service and API usage rules explained at https://core.telegram.org/api/obtaining_api_id.
1632

17-
3. Open the text editor of your choice and paste the following:
33+
3. **Create your first script** by opening your favorite text editor and pasting the following code:
1834

1935
.. code-block:: python
2036
2137
import asyncio
2238
from hydrogram import Client
2339
40+
# Replace these with your own values
2441
api_id = 12345
2542
api_hash = "0123456789abcdef0123456789abcdef"
2643
2744
2845
async def main():
46+
# Create a new client instance
2947
async with Client("my_account", api_id, api_hash) as app:
48+
# Send a message to yourself
3049
await app.send_message("me", "Greetings from **Hydrogram**!")
3150
51+
# Get information about yourself
52+
me = await app.get_me()
53+
print(f"Successfully logged in as {me.first_name} ({me.id})")
54+
3255
3356
asyncio.run(main())
3457
35-
4. Replace *api_id* and *api_hash* values with your own.
58+
4. **Replace** the placeholder ``api_id`` and ``api_hash`` values with your own.
59+
60+
5. **Save the file** as ``hello.py``.
3661

37-
5. Save the file as ``hello.py``.
62+
6. **Run the script** with ``python3 hello.py``
3863

39-
6. Run the script with ``python3 hello.py``
64+
7. **Log in to your account** by following the prompts. You'll only need to do this once.
4065

41-
7. Follow the instructions on your terminal to login.
66+
8. **Watch Hydrogram in action** as it sends a message to your Saved Messages.
4267

43-
8. Watch Hydrogram send a message to yourself.
68+
What's Next?
69+
------------
4470

45-
Enjoy the API
46-
-------------
71+
This was just a brief introduction to get you started quickly. Hydrogram offers many more powerful features for building Telegram applications.
4772

48-
That was just a quick overview. In the next few pages of the introduction, we'll take a much more in-depth look of what
49-
we have just done above.
73+
- Learn about different ways to :doc:`../start/invoking` from the API
74+
- Explore how to :doc:`../start/updates` from Telegram
75+
- Check out complete :doc:`../start/examples/index` to see what's possible
5076

51-
If you are feeling eager to continue you can take a shortcut to :doc:`../start/invoking` and come back
52-
later to learn some more details.
77+
Join our `community`_ on Telegram for support and updates.
5378

5479
.. _community: https://t.me/HydrogramNews

docs/source/topics/mtproto-vs-botapi.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ special accounts that are authorized via tokens instead of phone numbers. The Bo
3232
main Telegram API, but runs on an intermediate server application that in turn communicates with the actual Telegram
3333
servers using MTProto.
3434

35-
.. figure:: //_static/img/mtproto-vs-bot-api.png
35+
.. figure:: /_static/img/mtproto-vs-bot-api.png
3636
:align: center
3737

3838
.. _Bot API: https://core.telegram.org/bots/api

0 commit comments

Comments
 (0)