(no title)
bquinlan | 6 years ago
Python example:
from pybadges import badge
s = badge(left_text='coverage',
right_text='23%',
right_color='red')
# s is a string that contains the badge data as an svg image.
print(s[:40]) # => <svg height="20" width="191.0" xmlns="ht
Command line example: python -m pybadges \
--left-text="coverage" \
--right-text="23%" \
--right-color="red"
But there are lots more formatting options documented on the project page.
olivierlacan|6 years ago
Please consider contributing to Shields if you want to improve Python ecosystem support. We already support PyPI, Pipenv/GitHub, and a host of others. I'll gladly admit the interface for discovering badge types could use some improvement but the Shields community and maintainers have been working on that for a while.
We spent a lot of time designing, refining, adding support for hundreds of services and package managers, and offering a ridiculously simple to use API for everyone's metadata badge needs. So check out img.shields.io and see for yourself how you can already (lightly) customize badge styles to suit your taste.
https://img.shields.io/badge/contribute-please-red?style=fla...
Thanks :-)
cuu508|6 years ago
The template: https://raw.githubusercontent.com/healthchecks/healthchecks/...
And the function for rendering the template: https://github.com/healthchecks/healthchecks/blob/master/hc/...
One funky thing there is the measurement of text width. The width of the badge depends of the width of the text you put into it. I simply measured the width of each individual alphabet letter, and use that to calculate the width of a string. It's not super accurate, but works fine in practice. It was a fun weekend project.
bquinlan|6 years ago
You can also opt to use precise text width measurements (important for Arabic, Chinese, etc.) but then you have to have the font file available on your system.