Ticket #3024: sage-3024.patch

File sage-3024.patch, 2.7 KB (added by was, 13 years ago)
  • sage/server/notebook/cell.py

    # 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): 
    951951########
    952952
    953953def 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    """
    954971    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:
    956975        return s0
    957976    if ncols > 0:
    958977        s = s.strip()
  • sage/server/support.py

    diff -r 64bab8c54fd1 -r 3e870d7bb733 sage/server/support.py
    a b def help(obj): 
    8383    TESTS:
    8484        sage: import numpy.linalg
    8585        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">
    8787        Help on function norm in module numpy.linalg.linalg:
    8888        ...
    8989        For values ord < 0, the result is, strictly speaking, not a
    9090        mathematical 'norm', but it may still be useful for numerical purposes.
    9191        </font></tr></td></table></html>
    9292    """   
    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">'
    9494    pydoc.help(obj)
    9595    print '</font></tr></td></table></html>'
    9696