Skip to content

Commit 0ea512b

Browse files
committed
Update docs: add release notes from GitHub
1 parent a35e262 commit 0ea512b

5 files changed

Lines changed: 84 additions & 17 deletions

File tree

docs/releases.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram 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+
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
import shutil
20+
from datetime import datetime
21+
from pathlib import Path
22+
23+
import pypandoc
24+
import requests
25+
26+
URL = "https://api.github.com/repos/pyrogram/pyrogram/releases"
27+
DEST = Path("source/releases")
28+
INTRO = """
29+
Release Notes
30+
=============
31+
32+
Release notes for Pyrogram releases will describe what's new in each version, and will also make you aware of any
33+
backwards-incompatible changes made in that version.
34+
35+
When upgrading to a new version of Pyrogram, you will need to check all the breaking changes in order to find
36+
incompatible code in your application, but also to take advantage of new features and improvements.
37+
38+
Releases
39+
--------
40+
41+
""".lstrip("\n")
42+
43+
shutil.rmtree(DEST, ignore_errors=True)
44+
DEST.mkdir(parents=True)
45+
46+
releases = requests.get(URL).json()
47+
48+
with open(DEST / "index.rst", "w") as index:
49+
index.write(INTRO)
50+
51+
tags = []
52+
53+
for release in releases:
54+
tag = release["tag_name"]
55+
title = release["name"]
56+
name = title.split(" - ")[1]
57+
58+
date = datetime.strptime(
59+
release["published_at"],
60+
"%Y-%m-%dT%H:%M:%SZ"
61+
).strftime("%b %d, %Y - %H:%M:%S (UTC)")
62+
63+
body = pypandoc.convert_text(
64+
release["body"].replace(r"\r\n", "\n"),
65+
"rst",
66+
format="markdown_github",
67+
extra_args=["--wrap=none"]
68+
)
69+
70+
index.write("- :doc:`{} <{}>`\n".format(title, tag))
71+
tags.append(tag)
72+
73+
with open(DEST / "{}.rst".format(tag), "w") as page:
74+
page.write("Pyrogram " + tag + "\n" + "=" * (len(tag) + 9) + "\n\n")
75+
page.write("--- *Released on " + str(date) + "*\n\n")
76+
page.write(name + "\n" + "-" * len(name) + "\n\n")
77+
page.write(body + "\n\n")
78+
79+
index.write("\n.. toctree::\n :hidden:\n\n")
80+
index.write("\n".join(" {}".format(tag) for tag in tags))

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
html_theme_options = {
5959
"canonical_url": "https://docs.pyrogram.org/",
6060
"collapse_navigation": True,
61-
"sticky_navigation": False,
61+
"sticky_navigation": True,
6262
"logo_only": True,
6363
"display_version": True,
6464
"style_external_links": True

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ Meta
8383

8484
- :doc:`Pyrogram FAQ <faq>`: Answers to common Pyrogram questions.
8585
- :doc:`Pyrogram Glossary <glossary>`: List of words with brief explanations.
86-
- :doc:`Release Notes <releases>`: Release notes for Pyrogram releases.
8786
- :doc:`Powered by Pyrogram <powered-by>`: Collection of Pyrogram Projects.
8887
- :doc:`Support Pyrogram <support-pyrogram>`: Ways to show your appreciation.
8988
- :doc:`About the License <license>`: Information about the Project license.
89+
- :doc:`Release Notes <releases/index>`: Release notes for Pyrogram releases.
9090

9191
.. toctree::
9292
:hidden:
@@ -146,10 +146,10 @@ Meta
146146

147147
faq
148148
glossary
149-
releases
150149
powered-by
151150
support-pyrogram
152151
license
152+
releases/index
153153

154154
.. toctree::
155155
:hidden:

docs/source/releases.rst

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

docs/source/topics/more-on-updates.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ More on Updates
22
===============
33

44
Here we'll show some advanced usages when working with :doc:`update handlers <../start/updates>` and
5-
:doc:`filters <filters>`.
5+
:doc:`filters <use-filters>`.
66

77
Handler Groups
88
--------------

0 commit comments

Comments
 (0)