From 0ea512bbc3f672686da3cd562013def18df344ae Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 5 Jun 2019 11:05:01 +0200 Subject: [PATCH] Update docs: add release notes from GitHub --- docs/releases.py | 80 ++++++++++++++++++++++++++ docs/source/conf.py | 2 +- docs/source/index.rst | 4 +- docs/source/releases.rst | 13 ----- docs/source/topics/more-on-updates.rst | 2 +- 5 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 docs/releases.py delete mode 100644 docs/source/releases.rst diff --git a/docs/releases.py b/docs/releases.py new file mode 100644 index 00000000..98563ccd --- /dev/null +++ b/docs/releases.py @@ -0,0 +1,80 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2019 Dan Tès +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +import shutil +from datetime import datetime +from pathlib import Path + +import pypandoc +import requests + +URL = "https://api.github.com/repos/pyrogram/pyrogram/releases" +DEST = Path("source/releases") +INTRO = """ +Release Notes +============= + +Release notes for Pyrogram releases will describe what's new in each version, and will also make you aware of any +backwards-incompatible changes made in that version. + +When upgrading to a new version of Pyrogram, you will need to check all the breaking changes in order to find +incompatible code in your application, but also to take advantage of new features and improvements. + +Releases +-------- + +""".lstrip("\n") + +shutil.rmtree(DEST, ignore_errors=True) +DEST.mkdir(parents=True) + +releases = requests.get(URL).json() + +with open(DEST / "index.rst", "w") as index: + index.write(INTRO) + + tags = [] + + for release in releases: + tag = release["tag_name"] + title = release["name"] + name = title.split(" - ")[1] + + date = datetime.strptime( + release["published_at"], + "%Y-%m-%dT%H:%M:%SZ" + ).strftime("%b %d, %Y - %H:%M:%S (UTC)") + + body = pypandoc.convert_text( + release["body"].replace(r"\r\n", "\n"), + "rst", + format="markdown_github", + extra_args=["--wrap=none"] + ) + + index.write("- :doc:`{} <{}>`\n".format(title, tag)) + tags.append(tag) + + with open(DEST / "{}.rst".format(tag), "w") as page: + page.write("Pyrogram " + tag + "\n" + "=" * (len(tag) + 9) + "\n\n") + page.write("--- *Released on " + str(date) + "*\n\n") + page.write(name + "\n" + "-" * len(name) + "\n\n") + page.write(body + "\n\n") + + index.write("\n.. toctree::\n :hidden:\n\n") + index.write("\n".join(" {}".format(tag) for tag in tags)) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7ddeaa94..01fbe6de 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -58,7 +58,7 @@ html_show_copyright = False html_theme_options = { "canonical_url": "https://docs.pyrogram.org/", "collapse_navigation": True, - "sticky_navigation": False, + "sticky_navigation": True, "logo_only": True, "display_version": True, "style_external_links": True diff --git a/docs/source/index.rst b/docs/source/index.rst index 12ac705b..a2e08cd0 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -83,10 +83,10 @@ Meta - :doc:`Pyrogram FAQ `: Answers to common Pyrogram questions. - :doc:`Pyrogram Glossary `: List of words with brief explanations. - - :doc:`Release Notes `: Release notes for Pyrogram releases. - :doc:`Powered by Pyrogram `: Collection of Pyrogram Projects. - :doc:`Support Pyrogram `: Ways to show your appreciation. - :doc:`About the License `: Information about the Project license. + - :doc:`Release Notes `: Release notes for Pyrogram releases. .. toctree:: :hidden: @@ -146,10 +146,10 @@ Meta faq glossary - releases powered-by support-pyrogram license + releases/index .. toctree:: :hidden: diff --git a/docs/source/releases.rst b/docs/source/releases.rst deleted file mode 100644 index 6c3b5b75..00000000 --- a/docs/source/releases.rst +++ /dev/null @@ -1,13 +0,0 @@ -Release Notes -============= - -Release notes for Pyrogram releases will describe what's new in each version, and will also make you aware of any -backwards-incompatible changes made in that version. - -When upgrading to a new version of Pyrogram, you will need to check all the breaking changes in order to find -incompatible code in your application, but also to take advantage of new features and improvements. - -.. note:: - - Currently, all Pyrogram release notes live inside the GitHub repository web page: - https://github.com/pyrogram/pyrogram/releases. diff --git a/docs/source/topics/more-on-updates.rst b/docs/source/topics/more-on-updates.rst index c3737b38..df0aff7d 100644 --- a/docs/source/topics/more-on-updates.rst +++ b/docs/source/topics/more-on-updates.rst @@ -2,7 +2,7 @@ More on Updates =============== Here we'll show some advanced usages when working with :doc:`update handlers <../start/updates>` and -:doc:`filters `. +:doc:`filters `. Handler Groups --------------