def __call__(self, value: Any, *, indent: int=0, indent_first: bool=False, highlight: bool=False):
self._stream = io.StringIO()
self._format(value, indent_current=indent, indent_first=indent_first)
s = self._stream.getvalue()
if highlight and pyg_lexer:
# apparently highlight adds a trailing new line we don't want
s = pygments.highlight(s, lexer=pyg_lexer, formatter=pyg_formatter).rstrip('\n')
return s
评论列表
文章目录