From 4b8823e5633b22d13650cad6e06b0330ce9985fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Langa?= Date: Mon, 26 Mar 2018 02:11:16 -0700 Subject: [PATCH 1/1] Self-host PyPI-related badges --- .gitignore | 3 ++- README.md | 4 ++-- docs/_static/license.svg | 1 + docs/_static/pypi_template.svg | 1 + docs/conf.py | 12 ++++++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 docs/_static/license.svg create mode 100644 docs/_static/pypi_template.svg diff --git a/.gitignore b/.gitignore index 88f07d0..5d81454 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .coverage _build -.DS_Store \ No newline at end of file +.DS_Store +docs/_static/pypi.svg diff --git a/README.md b/README.md index dfbcc51..8aa0d06 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Build Status Documentation Status Coverage Status -License: MIT -PyPI +License: MIT +PyPI Code style: black

diff --git a/docs/_static/license.svg b/docs/_static/license.svg new file mode 100644 index 0000000..36bea29 --- /dev/null +++ b/docs/_static/license.svg @@ -0,0 +1 @@ +licenselicenseMITMIT \ No newline at end of file diff --git a/docs/_static/pypi_template.svg b/docs/_static/pypi_template.svg new file mode 100644 index 0000000..435d6bb --- /dev/null +++ b/docs/_static/pypi_template.svg @@ -0,0 +1 @@ +pypipypiv18.3a4$version diff --git a/docs/conf.py b/docs/conf.py index 19a161b..5d0e9e3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 @@ release = get_version() version = release for sp in 'abcfr': version = version.split(sp)[0] +make_pypi_svg(release) + # -- General configuration --------------------------------------------------- -- 2.39.2