def add_badge_roles(app):
from docutils.nodes import inline, make_id<EOL>from docutils.parsers.rst.roles import set_classes<EOL>def create_badge_role(color=None):<EOL><INDENT>def badge_role(name, rawtext, text, lineno, inliner,<EOL>options=None, content=None):<EOL><INDENT>options = options or {}<EOL>set_classes(options)<EOL>classes = ['<STR_LIT>']<EOL>if color is None:<EOL><INDENT>classes.append('<STR_LIT>' + make_id(text))<EOL><DEDENT>else:<EOL><INDENT>classes.append('<STR_LIT>' + color)<EOL><DEDENT>if len(text) == <NUM_LIT:1>:<EOL><INDENT>classes.append('<STR_LIT>')<EOL><DEDENT>options['<STR_LIT>'] = classes<EOL>node = inline(rawtext, text, **options)<EOL>return [node], []<EOL><DEDENT>return badge_role<EOL><DEDENT>app.add_role('<STR_LIT>', create_badge_role())<EOL>app.add_role('<STR_LIT>', create_badge_role('<STR_LIT>'))<EOL>app.add_role('<STR_LIT>', create_badge_role('<STR_LIT>'))<EOL>app.add_role('<STR_LIT>', create_badge_role('<STR_LIT>'))<EOL>app.add_role('<STR_LIT>', create_badge_role('<STR_LIT>'))<EOL>
Add ``badge`` role to your sphinx documents. It can create
    a colorful badge inline.