[Epydoc-commits] SF.net SVN: epydoc: [1331] trunk/epydoc/src/epydoc/docwriter/html.py
Brought to you by:
edloper
From: <ed...@us...> - 2006-08-29 21:37:52
|
Revision: 1331 Author: edloper Date: 2006-08-29 14:37:46 -0700 (Tue, 29 Aug 2006) ViewCVS: http://svn.sourceforge.net/epydoc/?rev=1331&view=rev Log Message: ----------- - Fixed SF bug [ 1546402 ] Latin 1 characters not recognized, by modifying pprint_pyval() to use decode_with_backslashreplace() when necessary to convert str repr's to unicode. - Changed pprint_pyval() to add color to quotes of unicode strings (not just str strings) Modified Paths: -------------- trunk/epydoc/src/epydoc/docwriter/html.py Modified: trunk/epydoc/src/epydoc/docwriter/html.py =================================================================== --- trunk/epydoc/src/epydoc/docwriter/html.py 2006-08-29 21:18:53 UTC (rev 1330) +++ trunk/epydoc/src/epydoc/docwriter/html.py 2006-08-29 21:37:46 UTC (rev 1331) @@ -144,6 +144,7 @@ pysrc_lines.append(' raise') pysrc = '\n'.join(pysrc_lines)+'\n' + #log.debug(pysrc) if debug: localdict = {'__debug': (pysrc_lines, func_name)} else: localdict = {} try: exec pysrc in globals(), localdict @@ -2296,18 +2297,22 @@ # For strings, use repr. Use tripple-quoted-strings where # appropriate. - elif type(pyval) is types.StringType: + elif isinstance(pyval, basestring): vstr = repr(pyval) + # Find the left quote. + lquote = vstr.find(vstr[-1]) + # Use tripple quotes if the string is multi-line: if vstr.find(r'\n') >= 0: - body = vstr[1:-1].replace(r'\n', '\n') - vstr = ('<span class="variable-quote">'+vstr[0]*3+'</span>'+ + body = vstr[lquote+1:-1].replace(r'\n', '\n') + vstr = ('<span class="variable-quote">'+vstr[:lquote]+ + vstr[lquote]*3+'</span>'+ plaintext_to_html(body) + - '<span class="variable-quote">'+vstr[0]*3+'</span>') - + '<span class="variable-quote">'+vstr[-1]*3+'</span>') + # Use single quotes if the string is single-line: else: - vstr = ('<span class="variable-quote">'+vstr[0]+'</span>'+ - plaintext_to_html(vstr[1:-1])+ - '<span class="variable-quote">'+vstr[0]+'</span>') + vstr = ('<span class="variable-quote">'+vstr[:lquote+1]+ + '</span>'+ plaintext_to_html(vstr[lquote+1:-1])+ + '<span class="variable-quote">'+vstr[-1:]+'</span>') # For lists, tuples, and dicts, use pprint. When possible, # restrict the amount of stuff that pprint needs to look at, @@ -2343,6 +2348,10 @@ try: vstr = plaintext_to_html(repr(pyval)) except: vstr = '...' + # Encode vstr, if necessary. + if isinstance(vstr, str): + vstr = decode_with_backslashreplace(vstr) + # Do line-wrapping. return self._linewrap_html(vstr, self._variable_linelen, self._variable_maxlines) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |