1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-10-05 14:57:08 +02:00

Current version and release date in doc sidebar

This commit is contained in:
Alexander Graf 2017-12-21 13:53:06 +01:00
parent 75d9dda4ba
commit 5695bca9f3
4 changed files with 23 additions and 1 deletions

View File

@ -10,6 +10,6 @@ https://instaloader.readthedocs.io/
The documentation is created with [Sphinx](http://www.sphinx-doc.org/). To build it, use
```
pip3 install sphinx sphinx-autodoc-typehints
pip3 install -r requirements.txt
make html
```

View File

@ -4,6 +4,11 @@
<li class="toctree-l1"><a class="reference internal" href="{{ next.link|e }}">{{ next.title }}</a></li>
</ul>
{% endif %}
<h3>Current Release</h3>
<ul>
<li class="toctree-l1"><a href="https://github.com/Thammus/instaloader/releases/tag/v{{current_release}}">Version <b>{{current_release}}</b></a></li>
<li>Released on <b>{{current_release_date}}</b>.</li>
</ul>
<h3>Links</h3>
<ul>
<li><a href="https://github.com/Thammus/instaloader/issues">Issue Tracker</a></li>

View File

@ -19,6 +19,9 @@
#
import os
import sys
import re
import requests
from datetime import datetime
sys.path.insert(0, os.path.abspath('..'))
# -- General configuration ------------------------------------------------
@ -352,3 +355,15 @@ texinfo_documents = [
# If true, do not generate a @detailmenu in the "Top" node's menu.
#
# texinfo_no_detailmenu = False
def get_latest_tag(repo):
tags = requests.get("https://api.github.com/repos/{}/git/refs/tags".format(repo)).json()
latest_tag = requests.get(tags[-1]['object']['url']).json()
version_string = latest_tag['tag']
version_date = datetime.strptime(latest_tag['tagger']['date'], "%Y-%m-%dT%H:%M:%SZ")
return version_string[1:], re.sub(r'\b0+(\d)', r'\1', "{:%d %b %Y}".format(version_date))
current_release, current_release_date = get_latest_tag('Thammus/instaloader')
html_context = {'current_release': current_release, 'current_release_date': current_release_date}

View File

@ -1 +1,3 @@
requests
sphinx
sphinx-autodoc-typehints