Skip to content

Commit 2787e8e

Browse files
committed
(refactor): Migrate documentation to separate repository
1 parent 189c850 commit 2787e8e

100 files changed

Lines changed: 198 additions & 7191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-docs.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ jobs:
1414
- uses: actions/checkout@v6
1515
with:
1616
fetch-depth: 1
17+
18+
- uses: actions/checkout@v6
19+
with:
20+
repository: TelegramPlayground/pyrogram-docs
21+
ref: master
22+
path: docs
23+
fetch-depth: 1
24+
1725
- name: Set up Python
1826
uses: actions/setup-python@v6
1927
with:
@@ -28,9 +36,18 @@ jobs:
2836
make
2937
cd ./docs/build/html && rm -rf .doctrees && cd ./../../..
3038
39+
- name: Generate GitHub App Token
40+
id: generate-token
41+
uses: actions/create-github-app-token@v1
42+
with:
43+
app-id: ${{ secrets.ORG_APP_ID }}
44+
private-key: ${{ secrets.ORG_APP_PRIVATE_KEY }}
45+
owner: TelegramPlayground
46+
3147
- uses: peaceiris/actions-gh-pages@v4
3248
with:
33-
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
personal_token: ${{ steps.generate-token.outputs.token }}
50+
external_repository: TelegramPlayground/pyrogram-docs
3451
publish_dir: ./docs/build/html
3552
publish_branch: gh-pages
3653
user_name: 'github-actions[bot]'

CONTRIBUTING.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Contributing to this Pyrogram Fork
2+
3+
Welcome, and thank you for your interest in contributing to this Pyrogram Fork!
4+
5+
Pyrogram was (and hopefully should continue to be) an open source project that depends on the generous help of contributors who volunteer their time and skills. We appreciate your involvement and support.
6+
7+
You can contribute in many ways, not only by writing code. This document aims to give you a high-level overview of how you can get involved.
8+
9+
## What Can I Do?
10+
11+
In short: anything you find useful!
12+
13+
If you’re unsure whether your changes are welcome, open an issue on GitHub or preferably ask in the [Telegram chat](https://t.me/pyrotgfork/2).
14+
15+
In case you’d like to get some inspiration what we're working on, we have
16+
17+
- a [long list of issues across all repositories](https://github.com/issues?q=is%3Aissue%20is%3Aopen%20(repo%3ATelegramPlayground%2Fpyrogram-docs%20OR%20repo%3ATelegramPlayground%2Fpyrogram%20OR%20repo%3ATelegramPlayground%2Fpyrogram-tgcrypto)%20sort%3Acreated-desc), and
18+
19+
There is usually also a [pinned issue](https://github.com/TelegramPlayground/pyrogram/issues) which tells you which issues need help.
20+
21+
## Asking Questions
22+
23+
If you have a question, please use the [Telegram Chat](https://t.me/pyrotgfork/2) instead of opening an issue. Simply start a message in the correct topic and our community will gladly answer.
24+
25+
## Providing Feedback
26+
27+
Feedback from the community is very important to us as the maintainers of this Pyrogram fork. If you have any suggestions, ideas, or concerns, please share them with us. You can use the [Telegram Chat](https://t.me/pyrotgfork/2) to start a conversation.
28+
29+
You might be wondering about the difference between asking questions, providing feedback, and making feature requests. Asking questions is about seeking help or clarification. Providing feedback involves sharing your thoughts and opinions on the existing features and the project as a whole. Feature requests, on the other hand, are about suggesting new features or improvements. See the next section for more details on feature requests.
30+
31+
## Creating Issues
32+
33+
Have you identified a reproducible problem in this Pyrogram fork? Do you have a feature request? Here is how you can report your issue as efficiently as possible.
34+
35+
### Look For an Existing Issue
36+
37+
Before creating a new issue, check the open issues to see if someone else has already reported the same problem or requested the same feature.
38+
39+
If you find an existing issue that is relevant to yours, you can comment on it and express your support or disagreement with a reaction:
40+
41+
- upvote 👍
42+
- downvote 👎
43+
44+
If none of the open issues match your case, then create a new issue following the guidelines below.
45+
46+
### How to Write a Bug Report
47+
48+
A bug report should contain the following information:
49+
50+
- A clear and descriptive title that summarizes the problem.
51+
- A brief description of what you were doing when the bug occurred, and what you expected to happen.
52+
- A detailed description of the actual behavior and how it differs from the expected behavior.
53+
- [Steps to reproduce the bug](https://stackoverflow.com/help/minimal-reproducible-example), preferably in as much detail as possible in text format.
54+
- The version of Pyrogram and the operating system you are using. Kindly refrain from reporting issues noticed incase you are unable to reproduce it consistently with this Pyrogram fork.
55+
- Any relevant error messages or logs.
56+
57+
### How to Write a Feature Request
58+
59+
A feature request should contain the following information:
60+
61+
- A clear and descriptive title that summarizes the feature.
62+
- A brief explanation of why you need this feature and how it would benefit the project and the community.
63+
- A detailed description of how the feature should work and what it should look like, preferably with examples.
64+
- Optionally any relevant links or references to similar features in other projects or applications.
65+
66+
## Creating a Pull Request
67+
68+
To contribute code to this Pyrogram fork, simply open a pull request by following the guide below.
69+
70+
You can read more about pull requests in the [GitHub docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
71+
72+
### Setting Up Development Environment
73+
74+
1. Fork this Pyrogram repository to your GitHub account.
75+
2. Clone your forked repository of Pyrogram to your computer:
76+
77+
```bash
78+
git clone https://github.com/<your username>/pyrogram
79+
cd pyrogram
80+
```
81+
82+
4. Add a track to the original repository:
83+
84+
```bash
85+
git remote add upstream https://github.com/TelegramPlayGround/pyrogram
86+
```
87+
88+
5. Install dependencies:
89+
90+
```bash
91+
pip install --force-reinstall .[dev]
92+
```
93+
94+
### Run tests
95+
96+
All changes should be tested:
97+
98+
```bash
99+
pytest tests
100+
```
101+
102+
Remember to write tests for your new features or modify the existing tests to cover your code changes. Testing is essential to ensure the quality and reliability of your code.
103+
104+
### Docs
105+
106+
We use Sphinx to generate documentation in the [docs](https://github.com/TelegramPlayground/pyrogram-docs) repository. You can edit the sources and preview the changes using a live-preview server with:
107+
108+
```bash
109+
make docs-live
110+
```
111+
112+
### Commit Messages
113+
114+
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), which provide a standardized and structured format for commit messages. This helps ensure clear and consistent communication about the changes made in each commit. The commit messages should have the following structure:
115+
116+
```
117+
<type>[optional scope]: <description>
118+
119+
[optional body]
120+
121+
[optional footer(s)]
122+
```
123+
124+
where:
125+
126+
- `<type>`: This is a keyword that indicates the kind of change that the commit introduces. It can be one of the following values: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, or `revert`.
127+
- `[optional scope]`: This is an optional identifier that specifies the scope of the change. It can be a module, a component, a file, or any other logical unit of the project.
128+
- `<description>`: This is a short and concise summary of the change in the present tense and imperative mood. It should not end with a period.
129+
- `[optional body]`: This is an optional section that provides more details and context about the change. It should be separated from the summary by a blank line and wrapped at 72 characters.
130+
- `[optional footer(s)]`: This is an optional section that provides additional information such as references to issues, breaking changes, or acknowledgments. It should be separated from the body by a blank line and follow the format `<key>: <value>`.
131+
132+
For example:
133+
134+
```
135+
feat(storage): support multiple database using orm
136+
137+
This commit adds support for multiple databases using the tortoise-orm. It also updates the configuration file to allow the user to specify the database type and connection string.
138+
139+
BREAKING CHANGE: The database configuration has changed. The user must update the configuration file to specify the database type and connection string.
140+
141+
Closes #123
142+
```
143+
144+
### Describing Changes
145+
146+
Write a concise summary of your changes in one or more sentences, so that bot developers can see what's new or updated in the library.
147+
148+
## Thank You
149+
150+
Your contributions to open source, large or small, make great projects like this possible. Thank you for taking the time to contribute.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ api:
3838
docs-live:
3939
make clean-docs
4040
make api
41-
cd compiler/docs && ../../$(PYTHON) compiler.py
41+
cd docs/compiler && ../../$(PYTHON) compiler.py
4242
$(VENV)/bin/sphinx-autobuild \
4343
--watch pyrogram --watch docs/resources \
4444
-b html "docs/source" "docs/build/html" -j auto
4545

4646
docs:
4747
make clean-docs
48-
cd compiler/docs && ../../$(PYTHON) compiler.py
48+
cd docs/compiler && ../../$(PYTHON) compiler.py
4949
$(VENV)/bin/sphinx-build \
5050
-b html "docs/source" "docs/build/html" -j auto
5151

compiler/api/compiler.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,19 @@ def get_references(t: str, kind: str):
216216
return None, 0
217217

218218

219+
def indent_desc(desc: str, indent: str = " ") -> str:
220+
lines = desc.splitlines()
221+
222+
if len(lines) <= 1:
223+
return desc
224+
225+
first, *rest = lines
226+
227+
return first + "\n" + "\n".join(
228+
(indent + line if line.strip() else "") for line in rest
229+
)
230+
231+
219232
# noinspection PyShadowingBuiltins
220233
def start(format: bool = False):
221234
shutil.rmtree(DESTINATION_PATH / "types", ignore_errors=True)
@@ -352,7 +365,7 @@ def start(format: bool = False):
352365
else:
353366
type_docs = "Telegram API base type."
354367

355-
docstring = type_docs
368+
docstring = indent_desc(type_docs)
356369

357370
docstring += f"\n\n Constructors:\n" \
358371
f" This base type has {constr_count} constructor{'s' if constr_count > 1 else ''} available.\n\n" \
@@ -417,7 +430,7 @@ def start(format: bool = False):
417430
arg_docs = combinator_docs.get(c.qualname, None)
418431

419432
if arg_docs:
420-
arg_docs = arg_docs["params"].get(arg_name, "N/A")
433+
arg_docs = indent_desc(arg_docs["params"].get(arg_name, "N/A"), indent=" ")
421434
else:
422435
arg_docs = "N/A"
423436

@@ -438,16 +451,22 @@ def start(format: bool = False):
438451
else:
439452
constructor_docs = "Telegram API type."
440453

441-
docstring += constructor_docs + "\n"
454+
docstring += indent_desc(constructor_docs) + "\n"
442455
docstring += f"\n Constructor of :obj:`~pyrogram.raw.base.{c.qualtype}`."
443456
else:
444457
function_docs = docs["method"].get(c.qualname, None)
445458

446459
if function_docs:
447-
docstring += function_docs.get("desc", "").strip() + "\n"
460+
docstring += indent_desc(function_docs.get("desc", "").strip()) + "\n"
448461

449462
if function_docs.get("usable-by", "") != "":
450463
docstring += "\n .. include:: /_includes/usable-by/" + function_docs["usable-by"] + ".rst\n "
464+
465+
if function_docs.get("can_use_without_auth"):
466+
docstring += "\n\n .. note::\n\n " + "This method can be used by not yet logged in connections."
467+
468+
if function_docs.get("can_use_business_connection"):
469+
docstring += "\n\n .. note::\n\n " + "This method can be invoked over a `business connection » <https://corefork.telegram.org/api/bots/connected-business-bots>`__"
451470
else:
452471
docstring += f"Telegram API function."
453472

compiler/docs/__init__.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)