Remove escape sequences from default strings in documentation

Note: to properly view some values in browser you need the browser to use 
patched font or fontconfig. Though there is not much difference between some 
cryptic escape sequence and singe wrongly displayed character.
This commit is contained in:
ZyX 2013-03-17 22:26:57 +04:00
parent 60cc0196e8
commit 674a211cda
1 changed files with 13 additions and 1 deletions

View File

@ -4,6 +4,18 @@ from inspect import ArgSpec, getargspec, formatargspec
from powerline.lib.threaded import ThreadedSegment, KwThreadedSegment
from itertools import count
try:
from __builtin__ import unicode
except ImportError:
unicode = lambda s, enc: s
def formatvalue(val):
if type(val) is str:
return '="' + unicode(val, 'utf-8').replace('"', '\\"').replace('\\', '\\\\') + '"'
else:
return '=' + repr(val)
class ThreadedDocumenter(autodoc.FunctionDocumenter):
'''Specialized documenter subclass for ThreadedSegment subclasses.'''
@ -58,7 +70,7 @@ class ThreadedDocumenter(autodoc.FunctionDocumenter):
args.insert(0, arg)
argspec = ArgSpec(args=args, varargs=argspec.varargs, keywords=argspec.keywords, defaults=tuple(defaults))
return formatargspec(*argspec).replace('\\', '\\\\')
return formatargspec(*argspec, formatvalue=formatvalue).replace('\\', '\\\\')
def setup(app):