A few documentation fixes for #7650.
diff r f71a0d166b4e sagenb/notebook/cell.py
a

b


68  68  Delete all output in this cell. This is not executed  it is an 
69  69  abstract function that must be overwritten in a derived class. 
70  70  
71   EXAMPLES: This function just raises a NotImplementedError, since it 
72   most be defined in derived class.:: 
 71  EXAMPLES: 
 72  
 73  This function just raises a NotImplementedError, since it 
 74  most be defined in derived class. 
 75  
 76  :: 
73  77  
74  78  sage: C = sagenb.notebook.cell.Cell_generic() 
75  79  sage: C.delete_output() 
… 
… 

485  489  sage: C # random output  depends on computer speed 
486  490  Cell 0; in=2+3, out= 
487  491  
488   And the cell is considered to have been evaluated.:: 
 492  And the cell is considered to have been evaluated. 
 493  
 494  :: 
489  495  
490  496  sage: C.evaluated() # random output  depends on computer speed 
491  497  True 
diff r f71a0d166b4e sagenb/notebook/interact.py
a

b


944  944  EXAMPLES:: 
945  945  
946  946  sage: sagenb.notebook.interact.InputBox('theta', Color('red'), type=Color)._adaptor('#aaaaaa',globals()) 
947   RGB color (0.66666666666666663, 0.66666666666666663, 0.66666666666666663) 
 947  RGB color (0.66..., 0.66..., 0.66..) 
948  948  """ 
949  949  if self.__type is None: 
950  950  return sage_eval(value, globs) 
… 
… 

2723  2723  ... 
2724  2724  ValueError: unknown color 'crayon' 
2725  2725  sage: color_selector('#abcdef', label='height', widget='jpicker') 
2726   Interact color selector labeled 'height', with default RGB color (0.6705882352941176, 0.80392156862745101, 0.93725490196078431), widget 'jpicker', and visible input box 
 2726  Interact color selector labeled 'height', with default RGB color (0.6..., 0.8..., 0.9...), widget 'jpicker', and visible input box 
2727  2727  sage: color_selector('abcdef', label='height', widget='jpicker') 
2728  2728  Traceback (most recent call last): 
2729  2729  ... 
diff r f71a0d166b4e sagenb/notebook/worksheet.py
a

b


877  877  OUTPUT: a Notebook object. 
878  878  
879  879  EXAMPLES: This really returns the Notebook object that is set as a 
880   global variable of the twist module.:: 
 880  global variable of the twist module. 
 881  
 882  :: 
881  883  
882  884  sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') 
883  885  sage: W = nb.create_new_worksheet('A Test Worksheet', 'admin') 
… 
… 

1229  1231   ``username``  string 
1230  1232  
1231  1233  EXAMPLES: We create a worksheet and rate it, then look at the 
1232   ratings.:: 
 1234  ratings. 
 1235  
 1236  :: 
1233  1237  
1234  1238  sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') 
1235  1239  sage: W = nb.create_new_worksheet('Publish Test', 'admin') 
… 
… 

1415  1419  
1416  1420  sage: W.move_to_archive('admin') 
1417  1421  
1418   The view is now archive.:: 
 1422  The view is now archive. 
 1423  
 1424  :: 
1419  1425  
1420  1426  sage: W.user_view('admin') 
1421  1427  0 
1422  1428  sage: sagenb.notebook.worksheet.ARCHIVED 
1423  1429  0 
1424  1430  
1425   For any other random viewer the view is set by default to ACTIVE.:: 
 1431  For any other random viewer the view is set by default to ACTIVE. 
 1432  
 1433  :: 
1426  1434  
1427  1435  sage: W.user_view('foo') 
1428  1436  1 
… 
… 

1740  1748  
1741  1749  OUTPUT: bool 
1742  1750  
1743   EXAMPLES: We create a notebook with one worksheet and two users.:: 
 1751  EXAMPLES: We create a notebook with one worksheet and two users. 
 1752  
 1753  :: 
1744  1754  
1745  1755  sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') 
1746  1756  sage: nb.add_user('sage','sage','sage@sagemath.org',force=True) 
… 
… 

1755  1765  False 
1756  1766  
1757  1767  After adding 'william' as a collaborator he can edit the 
1758   worksheet.:: 
 1768  worksheet. 
 1769  
 1770  :: 
1759  1771  
1760  1772  sage: W.add_collaborator('william') 
1761  1773  sage: W.user_can_edit('william') 
… 
… 

1776  1788   ``user``  string; the name of a user 
1777  1789  
1778  1790  EXAMPLES: We create a notebook with 2 users and 1 worksheet that 
1779   both view.:: 
 1791  both view. 
 1792  
 1793  :: 
1780  1794  
1781  1795  sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') 
1782  1796  sage: nb.add_user('wstein','sage','wstein@sagemath.org',force=True) 
… 
… 

1789  1803  ['wstein'] 
1790  1804  
1791  1805  We delete the sage user from the worksheet W. This makes wstein the 
1792   new owner.:: 
 1806  new owner. 
 1807  
 1808  :: 
1793  1809  
1794  1810  sage: W.delete_user('sage') 
1795  1811  sage: W.viewers() 
… 
… 

1797  1813  sage: W.owner() 
1798  1814  'wstein' 
1799  1815  
1800   Then we delete wstein from W, which makes the owner None:: 
 1816  Then we delete wstein from W, which makes the owner None. 
 1817  
 1818  :: 
1801  1819  
1802  1820  sage: W.delete_user('wstein') 
1803  1821  sage: W.owner() is None 
… 
… 

1805  1823  sage: W.viewers() 
1806  1824  [] 
1807  1825  
1808   Finally, we clean up.:: 
 1826  Finally, we clean up. 
 1827  
 1828  :: 
1809  1829  
1810  1830  sage: nb.delete() 
1811  1831  """ 
… 
… 

2135  2155  ignore all the IDs in the {{{}}} code block. 
2136  2156  
2137  2157  
2138   EXAMPLES: We create a new test notebook and a worksheet.:: 
 2158  EXAMPLES: 
 2159  
 2160  We create a new test notebook and a worksheet. 
 2161  
 2162  :: 
2139  2163  
2140  2164  sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') 
2141  2165  sage: nb.add_user('sage','sage','sage@sagemath.org',force=True) 
2142  2166  sage: W = nb.create_new_worksheet('Test Edit Save', 'sage') 
2143  2167  
2144   We set the contents of the worksheet using the edit_save command.:: 
 2168  We set the contents of the worksheet using the edit_save command. 
 2169  
 2170  :: 
2145  2171  
2146  2172  sage: W.edit_save('{{{\n2+3\n///\n5\n}}}\n{{{\n2+8\n///\n10\n}}}') 
2147  2173  sage: W 
… 
… 

2446  2472  sage: W.last_to_edit() 
2447  2473  'john' 
2448  2474  sage: W.date_edited() 
2449   time.struct_time(tm_year=2009, tm_mon=10, tm_mday=8, tm_hour=12, tm_min=23, tm_sec=20, tm_wday=3, tm_yday=281, tm_isdst=1) 
 2475  time.struct_time(tm_year=2009, tm_mon=10, ...) # Output depends on timezone 
2450  2476  sage: t = W.time_since_last_edited() # just test that call works 
2451  2477  """ 
2452  2478  username = str(username); tm = float(tm) 
… 
… 

2542  2568  sage: W = nb.create_new_worksheet('Test Edit Save', 'admin') 
2543  2569  
2544  2570  Now we set the worksheet to have two cells with the default id of 0 
2545   and another with id 10.:: 
 2571  and another with id 10. 
 2572  
 2573  :: 
2546  2574  
2547  2575  sage: W.edit_save('{{{\n2+3\n///\n5\n}}}\n{{{id=10\n2+8\n///\n10\n}}}') 
2548  2576  sage: W.cell_id_list() 
… 
… 

3155  3183  sage: W.check_comp() 
3156  3184  ('w', Cell 0; in=factor(2^9971), out=...) 
3157  3185  
3158   We interrupt it successfully.:: 
 3186  We interrupt it successfully. 
 3187  
 3188  :: 
3159  3189  
3160  3190  sage: W.interrupt() # random  could fail on heavily loaded machine 
3161  3191  True 
3162  3192  
3163   Now we check and nothing is computing.:: 
 3193  Now we check and nothing is computing. 
 3194  
 3195  :: 
3164  3196  
3165  3197  sage: W.check_comp() # random  could fail on heavily loaded machine 
3166  3198  ('e', None) 
3167  3199  
3168   Clean up.:: 
 3200  Clean up. 
 3201  
 3202  :: 
3169  3203  
3170  3204  sage: W.quit() 
3171  3205  sage: nb.delete() 
… 
… 

3519  3553  l += k+1 
3520  3554  I = C._before_preparse.split('\n') 
3521  3555  out = out[:i + len(tb)+1] + ' ' + I[n2] + out[l:] 
3522   except (ValueError, IndexError), msg: 
 3556  except (ValueError, IndexError) as msg: 
3523  3557  pass 
3524  3558  return out 
3525  3559  
… 
… 

3653  3687  cur = os.path.abspath(os.curdir) 
3654  3688  try: 
3655  3689  mod, dir = cython.cython(filename_orig, compile_message=True, use_cache=True) 
3656   except (IOError, OSError, RuntimeError), msg: 
 3690  except (IOError, OSError, RuntimeError) as msg: 
3657  3691  return "print r'''Error compiling cython file:\n%s'''"%msg 
3658  3692  t = "import sys\n" 
3659  3693  t += "sys.path.append('%s')\n"%dir 
… 
… 

3744  3778  
3745  3779   ``C``  the cell object 
3746  3780  
3747   EXAMPLES: First, we set up a new notebook and worksheet.:: 
 3781  EXAMPLES: First, we set up a new notebook and worksheet. 
 3782  
 3783  :: 
3748  3784  
3749  3785  sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') 
3750  3786  sage: nb.add_user('sage','sage','sage@sagemath.org',force=True) 
3751  3787  sage: W = nb.create_new_worksheet('Test', 'sage') 
3752  3788  
3753  3789  We first test running a native command in 'sage' mode and then a 
3754   GAP cell within Sage mode.:: 
 3790  GAP cell within Sage mode. 
 3791  
 3792  :: 
3755  3793  
3756  3794  sage: W.edit_save('{{{\n2+3\n}}}\n\n{{{\n%gap\nSymmetricGroup(5)\n}}}') 
3757  3795  sage: c0, c1 = W.cell_list() 
… 
… 

3774  3812  Sym( [ 1 .. 5 ] ) 
3775  3813  ) 
3776  3814  
3777   Next, we run the same commands but from 'gap' mode.:: 
 3815  Next, we run the same commands but from 'gap' mode. 
 3816  
 3817  :: 
3778  3818  
3779  3819  sage: W.edit_save('{{{\n%sage\n2+3\n}}}\n\n{{{\nSymmetricGroup(5)\n}}}') 
3780  3820  sage: W.set_system('gap') 
… 
… 

3842  3882  deletion. 
3843  3883  
3844  3884  EXAMPLES: We create a new notebook, user, and a worksheet with one 
3845   cell.:: 
 3885  cell. 
 3886  
 3887  :: 
3846  3888  
3847  3889  sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') 
3848  3890  sage: nb.add_user('sage','sage','sage@sagemath.org',force=True) 
3849  3891  sage: W = nb.create_new_worksheet('Test', 'sage') 
3850  3892  sage: W.edit_save('{{{\n2+3\n///\n5\n}}}') 
3851  3893  
3852   Notice that there is 1 cell with 5 in its output.:: 
 3894  Notice that there is 1 cell with 5 in its output. 
 3895  
 3896  :: 
3853  3897  
3854  3898  sage: W.cell_list() 
3855  3899  [Cell 0; in=2+3, out= 
3856  3900  5] 
3857  3901  
3858   We now delete the output, observe that it is gone.:: 
 3902  We now delete the output, observe that it is gone. 
 3903  
 3904  :: 
3859  3905  
3860  3906  sage: W.delete_all_output('sage') 
3861  3907  sage: W.cell_list() 
3862  3908  [Cell 0; in=2+3, out=] 
3863  3909  
3864   If an invalid user tries to delete all, a ValueError is raised.:: 
 3910  If an invalid user tries to delete all, a ValueError is raised. 
 3911  
 3912  :: 
3865  3913  
3866  3914  sage: W.delete_all_output('hacker') 
3867  3915  Traceback (most recent call last): 
3868  3916  ... 
3869  3917  ValueError: user 'hacker' not allowed to edit this worksheet 
3870  3918  
3871   Clean up.:: 
 3919  Clean up. 
 3920  
 3921  :: 
3872  3922  
3873  3923  sage: nb.delete() 
3874  3924  """ 