-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathbuild_examples.py
55 lines (43 loc) · 1.61 KB
/
build_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from pathlib import Path
import anybadge
def color_examples_table():
"""Output the Markdown table containing color examples."""
print(
"""
| Color Name | Hex | Example |
| ------------- | ------- | ------- |"""
)
for color in sorted(anybadge.colors.Color):
file = "examples/color_" + color.name.lower() + ".svg"
url = "https://cdn.rawgit.com/jongracecox/anybadge/master/" + file
anybadge.Badge(
label="Color", value=color.name.lower(), default_color=color.value
).write_badge(file, overwrite=True)
print(
f"| {color.name.lower():<13} | {color.value.upper():<7} | ![]({f'{url})':<84}|"
)
def other_examples():
"""Generate emoji example badges used in documentation."""
examples_dir = Path(__file__).parent / Path("examples")
for label, value, file, kwargs in [
("Pipeline status", "😄", "pipeline_smile.svg", {}),
(
"Pipeline status",
"😄",
"pipeline_smile_padding.svg",
{"num_value_padding_chars": 1},
),
("Pipeline status", "😟", "pipeline_frown.svg", {"default_color": "Red"}),
("🔗", "Documentation", "documentation_link.svg", {}),
("🔗", "PyPi", "pypi_link.svg", {}),
("", "Value only", "value_only.svg", {}),
("Label only", "", "label_only.svg", {}),
]:
anybadge.Badge(label=label, value=value, **kwargs).write_badge(
examples_dir / Path(file), overwrite=True
)
def main():
color_examples_table()
other_examples()
if __name__ == "__main__":
main()