Self-host PyPI-related badges

This commit is contained in:
Łukasz Langa 2018-03-26 02:11:16 -07:00
parent 74f8c1316c
commit 4b8823e563
5 changed files with 18 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
.coverage
_build
.DS_Store
.DS_Store
docs/_static/pypi.svg

View File

@ -5,8 +5,8 @@
<a href="https://travis-ci.org/ambv/black"><img alt="Build Status" src="https://travis-ci.org/ambv/black.svg?branch=master"></a>
<a href="http://black.readthedocs.io/en/latest/?badge=latest"><img alt="Documentation Status" src="http://readthedocs.org/projects/black/badge/?version=latest"></a>
<a href="https://coveralls.io/github/ambv/black?branch=master"><img alt="Coverage Status" src="https://coveralls.io/repos/github/ambv/black/badge.svg?branch=master"></a>
<a href="https://github.com/ambv/black/blob/master/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-7900CA.svg"></a>
<img alt="PyPI" src="https://img.shields.io/pypi/v/black.svg">
<a href="https://github.com/ambv/black/blob/master/LICENSE"><img alt="License: MIT" src="http://black.readthedocs.io/en/latest/_static/license.svg"></a>
<a href="https://pypi.python.org/pypi/black"><img alt="PyPI" src="http://black.readthedocs.io/en/latest/_static/pypi.svg"></a>
<a href="https://github.com/ambv/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>

1
docs/_static/license.svg vendored Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="78" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="78" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h47v20H0z"/><path fill="#7900CA" d="M47 0h31v20H47z"/><path fill="url(#b)" d="M0 0h78v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"><text x="245" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="370">license</text><text x="245" y="140" transform="scale(.1)" textLength="370">license</text><text x="615" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">MIT</text><text x="615" y="140" transform="scale(.1)" textLength="210">MIT</text></g> </svg>

After

Width:  |  Height:  |  Size: 949 B

1
docs/_static/pypi_template.svg vendored Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="88" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="88" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h55v20H33z"/><path fill="url(#b)" d="M0 0h88v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"><text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="595" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="450">v18.3a4</text><text x="595" y="140" transform="scale(.1)" textLength="450">$version</text></g> </svg>

After

Width:  |  Height:  |  Size: 953 B

View File

@ -15,6 +15,7 @@
import ast
from pathlib import Path
import re
import string
from recommonmark.parser import CommonMarkParser
@ -30,6 +31,15 @@ def get_version():
return str(ast.literal_eval(version))
def make_pypi_svg(version):
template = CURRENT_DIR / '_static' / 'pypi_template.svg'
target = CURRENT_DIR / '_static' / 'pypi.svg'
with open(str(template), 'r', encoding='utf8') as f:
svg = string.Template(f.read()).substitute(version=version)
with open(str(target), 'w', encoding='utf8') as f:
f.write(svg)
# -- Project information -----------------------------------------------------
project = 'Black'
@ -43,6 +53,8 @@ def get_version():
version = release
for sp in 'abcfr':
version = version.split(sp)[0]
make_pypi_svg(release)
# -- General configuration ---------------------------------------------------