1 from os
.path
import dirname
, join
5 # Try to load JSON data from a file. If not found, use the argument as a tag name and retrieve the data from GitHub.
6 def getJSON(tag
='all'):
14 d
= json
.loads(open(join(dirname(__file__
), f
+'.json'), 'r').read())
16 from urllib
.request
import urlopen
17 d
= json
.loads(urlopen('https://api.github.com/repos/ghdl/ghdl/releases'+tag
).read())
18 json
.dump(d
, open(f
+'.json', 'w'), indent
=4)
22 # Print two versions of each shield. Onee for 'html' (`image::`) and one for 'latex' (`replace::`)
25 def printShieldSrc(label
, alt
, img
, target
, latex
=False):
27 if label
[-6:] == '/total':
29 idx
= re
.compile('[\W_]+').sub('', label
)
31 .. |l{idx}| replace:: `{label}`_
36 .. |{label}| image:: {img}
44 # Create shields/badges from JSON file
47 def createShields(file='shields'):
48 shields
= getJSON(file)
49 for k
, v
in shields
.items():
52 t
= 'https://github.com/' + t
[3:]
57 'https://img.shields.io/' + v
['src'] + '&style=flat-square&longCache=true',