# HG changeset patch # User William Stein # Date 1210493093 25200 # Node ID 3e870d7bb73320d61deea4fabe7419aedb048cfd # Parent 64bab8c54fd187e3860c10ba5629f6b3235cba98 trac #3024 -- notebook -- parses tracebacks in the output of docstrings of help command I fixed this for help(foo). diff -r 64bab8c54fd1 -r 3e870d7bb733 sage/server/notebook/cell.py --- a/sage/server/notebook/cell.py Sun May 11 00:49:30 2008 -0700 +++ b/sage/server/notebook/cell.py Sun May 11 01:04:53 2008 -0700 @@ -951,8 +951,27 @@ class Cell(Cell_generic): ######## def format_exception(s0, ncols): + """ + Make it so excpetions don't appear expanded by default. + + INPUT: + s0 -- string + ncols -- integer + OUTPUT: + string + + If s0 contains "notracebacks" then this function always returns s0 + + EXAMPLES: + sage: sage.server.notebook.cell.format_exception(sage.server.notebook.cell.TRACEBACK,80) + '\nTraceback (click to the left for traceback)\n...\nTraceback (most recent call last):' + sage: sage.server.notebook.cell.format_exception(sage.server.notebook.cell.TRACEBACK + "notracebacks",80) + 'Traceback (most recent call last):notracebacks' + """ s = s0.lstrip() - if TRACEBACK not in s: + # Add a notracebacks option -- if it is in the string then tracebacks aren't shrunk. + # This is currently used by the sage.server.support.help command. + if TRACEBACK not in s or 'notracebacks' in s: return s0 if ncols > 0: s = s.strip() diff -r 64bab8c54fd1 -r 3e870d7bb733 sage/server/support.py --- a/sage/server/support.py Sun May 11 00:49:30 2008 -0700 +++ b/sage/server/support.py Sun May 11 01:04:53 2008 -0700 @@ -83,14 +83,14 @@ def help(obj): TESTS: sage: import numpy.linalg sage: sage.server.support.help(numpy.linalg.norm) -
+
Help on function norm in module numpy.linalg.linalg: ... For values ord < 0, the result is, strictly speaking, not a mathematical 'norm', but it may still be useful for numerical purposes.
""" - print '
' + print '
' pydoc.help(obj) print '
'