Skip to content

Commit

Permalink
Added test for render_badge and fixed KeyError.
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
jaraco committed Jun 10, 2024
1 parent b90ce72 commit aff7949
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def inject_badges(readme, type):


def render_badge(type, *, image, target=None, alt_text=''):
"""
>>> print(render_badge('markdown', image='file://foo.img', alt_text='foo'))
![foo](file://foo.img)
>>> print(render_badge('rst', image='file://foo.img', alt_text='foo'))
.. image:: file://foo.img
:alt: foo
"""
markdown = join(
'[' * bool(target),
'![{alt_text}]({image})',
Expand All @@ -233,7 +240,7 @@ def render_badge(type, *, image, target=None, alt_text=''):
rst = join(
'.. image:: {image}',
'\n :target: {target}' * bool(target),
'\n :alt: {name}' * bool(alt_text),
'\n :alt: {alt_text}' * bool(alt_text),
)
return locals().get(type, markdown).format_map(locals())

Expand Down

0 comments on commit aff7949

Please sign in to comment.