# HG changeset patch
# User William Stein <wstein@gmail.com>
# 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
|
b
|
class Cell(Cell_generic): |
951 | 951 | ######## |
952 | 952 | |
953 | 953 | def format_exception(s0, ncols): |
| 954 | """ |
| 955 | Make it so excpetions don't appear expanded by default. |
| 956 | |
| 957 | INPUT: |
| 958 | s0 -- string |
| 959 | ncols -- integer |
| 960 | OUTPUT: |
| 961 | string |
| 962 | |
| 963 | If s0 contains "notracebacks" then this function always returns s0 |
| 964 | |
| 965 | EXAMPLES: |
| 966 | sage: sage.server.notebook.cell.format_exception(sage.server.notebook.cell.TRACEBACK,80) |
| 967 | '\nTraceback (click to the left for traceback)\n...\nTraceback (most recent call last):' |
| 968 | sage: sage.server.notebook.cell.format_exception(sage.server.notebook.cell.TRACEBACK + "notracebacks",80) |
| 969 | 'Traceback (most recent call last):notracebacks' |
| 970 | """ |
954 | 971 | s = s0.lstrip() |
955 | | if TRACEBACK not in s: |
| 972 | # Add a notracebacks option -- if it is in the string then tracebacks aren't shrunk. |
| 973 | # This is currently used by the sage.server.support.help command. |
| 974 | if TRACEBACK not in s or 'notracebacks' in s: |
956 | 975 | return s0 |
957 | 976 | if ncols > 0: |
958 | 977 | s = s.strip() |
diff -r 64bab8c54fd1 -r 3e870d7bb733 sage/server/support.py
a
|
b
|
def help(obj): |
83 | 83 | TESTS: |
84 | 84 | sage: import numpy.linalg |
85 | 85 | sage: sage.server.support.help(numpy.linalg.norm) |
86 | | <html><table notruncate bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d"> |
| 86 | <html><table notruncate notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d"> |
87 | 87 | Help on function norm in module numpy.linalg.linalg: |
88 | 88 | ... |
89 | 89 | For values ord < 0, the result is, strictly speaking, not a |
90 | 90 | mathematical 'norm', but it may still be useful for numerical purposes. |
91 | 91 | </font></tr></td></table></html> |
92 | 92 | """ |
93 | | print '<html><table notruncate bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d">' |
| 93 | print '<html><table notruncate notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d">' |
94 | 94 | pydoc.help(obj) |
95 | 95 | print '</font></tr></td></table></html>' |
96 | 96 | |