Ticket #6840: trac_6840-notebook-documentation-v2.patch

File trac_6840-notebook-documentation-v2.patch, 112.6 KB (added by timdumol, 12 years ago)

Merged changes from #5360. Apply only this file.

  • doc/en/reference/notebook.rst

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1249912330 25200
    # Node ID 37265ae04e84b07cd71367819c6e85ccfbeb18f8
    # Parent  832b4605800675c661715a511041de9ea77904a7
    #6840 Fixes documentation for sage.server.*
    
    diff -r 832b46058006 -r 37265ae04e84 doc/en/reference/notebook.rst
    a b  
    1111   sage/server/notebook/worksheet
    1212   sage/server/notebook/twist
    1313
     14   sage/server/notebook/interact
    1415   sage/server/notebook/js
    1516   sage/server/notebook/config
    1617   sage/server/notebook/css
     18   sage/server/notebook/docHTMLProcessor
     19   sage/server/notebook/template
    1720
     21   sage/server/misc
    1822   sage/server/support
    1923   sage/server/introspect
    2024
  • sage/server/introspect.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/introspect.py
    a b  
    11"""
    2 Sage Notebook: Introspection
     2Sage Notebook Introspection
    33
    44TODO: - add support for grabbing source code from Pyrex functions
    55(even if not perfect is better than nothing). - PNG or MathML
  • sage/server/misc.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/misc.py
    a b  
    11"""
    2 Misc code useful for the notebook
     2Miscellaneous Notebook Functions
    33"""
    44
    55#############################################################################
     
    2424        secure -- bool (default: False); whether to put HTTP or HTTPS
    2525        path -- path after the port.
    2626
    27     EXAMPLES:   
     27    EXAMPLES::
     28
    2829        sage: sage.server.misc.print_open_msg('localhost', 8000, True)
    2930        ****************************************************
    3031        *                                                  *
     
    8485    OUTPUT:
    8586        an integer, or if no port is found, raises a RuntimError exception
    8687
    87     EXAMPLES:
     88    EXAMPLES::
     89
    8890        sage: sage.server.misc.find_next_available_port(9000, verbose=False)   # random output -- depends on network
    8991        9002
    9092    """
  • sage/server/notebook/avatars.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/avatars.py
    a b  
    2828    OUTPUT:
    2929        string -- 'invalid_user', 'admin', 'user'
    3030   
    31     EXAMPLES:
     31    EXAMPLES::
     32
    3233        sage: import sage.server.notebook.twist
    3334        sage: import sage.server.notebook.avatars as avatars
    3435        sage: avatars.user_type(avatars.FailedLogin('fake'))
  • sage/server/notebook/cell.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/cell.py
    a b  
    19101910            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    19111911            sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
    19121912            sage: W = nb.create_new_worksheet('Test', 'sage')
    1913             sage: C = sage.server.notebook.cell.Cell(0, 'plot(sin(x),0,5)', ", W)
     1913            sage: C = sage.server.notebook.cell.Cell(0, 'plot(sin(x),0,5)', '', W)
    19141914            sage: C.evaluate()
    19151915            sage: W.check_comp(wait=9999)
    19161916            ('d', Cell 0; in=plot(sin(x),0,5), out=
     
    19371937            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    19381938            sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
    19391939            sage: W = nb.create_new_worksheet('Test', 'sage')
    1940             sage: C = sage.server.notebook.cell.Cell(0, 'plot(sin(x),0,5)', ", W)
     1940            sage: C = sage.server.notebook.cell.Cell(0, 'plot(sin(x),0,5)', '', W)
    19411941            sage: C.evaluate()
    19421942            sage: W.check_comp(wait=9999)
    19431943            ('d', Cell 0; in=plot(sin(x),0,5), out=
  • sage/server/notebook/config.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/config.py
    a b  
    11"""
    2 Customization of the Notebook Keybindings
     2Notebook Keybindings
    33
    44This module is responsible for setting the keyboard bindings for the notebook.
    55"""
  • sage/server/notebook/css.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/css.py
    a b  
    11"""nodoctest
    2 Sage Notebook CSS
     2Notebook Stylesheets (CSS)
    33"""
    44
    55
  • sage/server/notebook/docHTMLProcessor.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/docHTMLProcessor.py
    a b  
    3535        This function is called by SGMLParser.__init__ so all necessary things
    3636        are initialized here.
    3737
    38         EXAMPLES:
     38        EXAMPLES::
     39
    3940            sage: from sage.server.notebook.docHTMLProcessor import SphinxHTMLProcessor
    4041            sage: d = SphinxHTMLProcessor()
    4142            sage: d.bodyQ
     
    103104        Returns the current cell count and increments it
    104105        by one.
    105106
    106         EXAMPLES:
     107        EXAMPLES::
     108
    107109            sage: from sage.server.notebook.docHTMLProcessor import SphinxHTMLProcessor
    108110            sage: d = SphinxHTMLProcessor()
    109111            sage: d.get_cellcount()
     
    217219        """
    218220        This just sets self.bodyQ to True once we've hit the body tag.
    219221
    220         EXAMPLES:
     222        EXAMPLES::
     223
    221224            sage: from sage.server.notebook.docHTMLProcessor import SphinxHTMLProcessor
    222225            sage: d = SphinxHTMLProcessor()
    223226            sage: d.bodyQ
  • sage/server/notebook/interact.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/interact.py
    a b  
    66#############################################################################
    77
    88r"""
    9 Interact Sage functions in the notebook
     9Interact Functions in the Notebook
    1010
    11 This module implements a interact decorator for function in the Sage
     11This module implements an ``interact`` function decorator for the Sage
    1212notebook.
    1313
    1414AUTHORS:
    15     -- William Stein (2008-03-02): version 1.0 at Sage/Enthought Days 8 in Texas
     15
     16    -- William Stein (2008-03-02): version 1.0 at Sage/Enthought Days
     17       8 in Texas
     18
    1619    -- Jason Grout (2008-03): discussion and first few prototypes
    17     -- Jason Grout (2008-05): input_grid control
     20
     21    -- Jason Grout (2008-05): ``input_grid`` control
    1822"""
    1923
    2024"""
     
    158162
    159163def reset_state():
    160164    """
    161     Reset the interact state of this sage process.
     165    Reset the ``interact`` state of this sage process.
    162166
    163     EXAMPLES:
     167    EXAMPLES::
     168
    164169        sage: sage.server.notebook.interact.state  # random output
    165170        {1: {'function': <function g at 0x72aaab0>, 'variables': {'m': 3, 'n': 5}, 'adapt': {1: <bound method Slider._adaptor of Slider Interact Control: n [1--|1|---10].>, 2: <bound method Slider._adaptor of Slider Interact Control: m [1--|1|---10].>}}}
    166171        sage: from sage.server.notebook.interact import reset_state
     
    174179_k = 0
    175180def new_adapt_number():
    176181    """
    177     Return an integer, always counting up, and starting with 0.  This
     182    Return an integer, always counting up, and starting with ``0``.  This
    178183    is used for saving the adapt methods for controls.  An adapt
    179184    method is just a function that coerces data into some object,
    180185    e.g., makes sure the control always produces int's.
    181186
    182187    OUTPUT:
     188
    183189        integer
    184190
    185     EXAMPLES:
     191    EXAMPLES::
     192
    186193        sage: sage.server.notebook.interact.new_adapt_number()   # random output -- depends on when called
    187194        1   
    188195    """
     
    193200
    194201def html(s):
    195202    """
    196     Render the input string s in a form that tells the notebook
     203    Render the input string ``s`` in a form that tells the notebook
    197204    to display it in the HTML portion of the output.
    198205
    199206    INPUT:
    200         s -- a string
     207
     208        ``s`` -- a string
    201209
    202210    OUTPUT:
    203         string -- html format
    204211
    205     EXAMPLES:
     212        string -- HTML format
     213
     214    EXAMPLES::
     215
    206216        sage: sage.server.notebook.interact.html('hello')
    207217        <html>hello</html>   
    208218    """
     
    213223    Return the HTML representation of a jQuery slider.
    214224
    215225    INPUT:
    216         id      -- string -- the DOM id of the slider (better be unique)
    217         values  -- 'null' or javascript string containing array of values on slider
    218         callback-- javascript that is executed whenever the slider is done moving
    219         steps   -- number of steps from minimum to maximum value.
    220         default -- (default: 0) the default position of the slider
    221         margin  -- (default: 0) size of margin to insert around the slider
     226
     227        ``id``      -- string -- the DOM id of the slider (better be unique)
     228
     229        ``values`` -- 'null' or JavaScript string containing array of
     230        values on slider
     231
     232        ``callback`` -- JavaScript that is executed whenever the
     233        slider is done moving
     234
     235        ``steps`` -- number of steps from minimum to maximum value.
     236
     237        ``default`` -- (default: ``0``) the default position of the
     238        slider
     239
     240        ``margin`` -- (default: ``0``) size of margin to insert around
     241        the slider
    222242
    223243    EXAMPLES:
     244
    224245    We create a jQuery HTML slider.    If you do the following in the notebook
    225246    you should obtain a slider that when moved pops up a window showing its
    226     current position.
     247    current position::
     248
    227249        sage: from sage.server.notebook.interact import html_slider, html
    228250        sage: html(html_slider('slider-007', 'null', 'alert(position)', steps=5, default=2, margin=5))
    229251        <html>...</html>
     
    257279    Return the HTML representation of a jQuery range slider.
    258280
    259281    INPUT:
    260         id      -- string -- the DOM id of the slider (better be unique)
    261         values  -- 'null' or javascript string containing array of values on slider
    262         callback-- javascript that is executed whenever the slider is done moving
    263         steps   -- number of steps from minimum to maximum value.
    264         default_l -- (default: 0) the default position of the left edge of the slider
    265         default_r -- (default: 1) the default position of the right edge of the slider
    266         margin  -- (default: 0) size of margin to insert around the slider
     282
     283        ``id`` -- string -- the DOM id of the slider (better be
     284        unique)
     285
     286        ``values`` -- 'null' or JavaScript string containing array of
     287        values on slider
     288
     289        ``callback`` -- JavaScript that is executed whenever the
     290        slider is done moving
     291
     292        ``steps`` -- number of steps from minimum to maximum value.
     293
     294        ``default_l`` -- (default: ``0``) the default position of the left
     295        edge of the slider
     296
     297        ``default_r`` -- (default: ``1``) the default position of the
     298        right edge of the slider
     299
     300        ``margin`` -- (default: ``0``) size of margin to insert around the
     301        slider
    267302
    268303    EXAMPLES:
    269     We create a jQuery range slider. If you do the following in the notebook
    270     you should obtain a slider that when moved pops up a window showing its
    271     current position.
     304
     305    We create a jQuery range slider. If you do the following in the
     306    notebook you should obtain a slider that when moved pops up a
     307    window showing its current position::
     308
    272309        sage: from sage.server.notebook.interact import html_rangeslider, html
    273310        sage: html(html_rangeslider('slider-007', 'null', 'alert(pos[0]+", "+pos[1])', steps=5, default_l=2, default_r=3, margin=5))
    274311        <html>...</html>
     
    324361    Return HTML representation of a jQuery color selector.
    325362
    326363    INPUT:
    327         id -- integer; the id of the html div element that this selector should have
    328         change -- javascript code to execute when the color selector changes.
    329         default -- string (default: '000000'); default color as a 6-character
    330                    HTML hex string.
     364
     365        ``id`` -- integer; the id of the HTML div element that this
     366        selector should have
     367
     368        ``change`` -- JavaScript code to execute when the color
     369        selector changes.
     370
     371        ``default`` -- string (default: ``'000000'``); default color as a
     372                   6-character HTML hex string.
    331373
    332374    OUTPUT:
     375
    333376        string -- HTML that creates the slider.
    334377
    335     EXAMPLES:
     378    EXAMPLES::
     379
    336380        sage: sage.server.notebook.interact.html_color_selector(0, 'alert("changed")', '', default='0afcac')
    337381        '<table>...'
    338382    """
     
    366410        Returns an empty label for this element. This should be
    367411        overridden for subclasses that need a label.
    368412
    369         EXAMPLES:
     413        EXAMPLES::
     414
    370415            sage: from sage.server.notebook.interact import UpdateButton, InteractElement
    371416            sage: b = UpdateButton(1)
    372417            sage: isinstance(b, InteractElement)
     
    378423   
    379424    def set_canvas(self, canvas):
    380425        """
    381         Sets the InteractCanvas on which this element appears.  This
    382         method is primarily called in the constructor for
    383         InteractCanvas.
     426        Sets the ``InteractCanvas`` on which this element appears.
     427        This method is primarily called in the constructor for
     428        ``InteractCanvas``.
    384429
    385         EXAMPLES:
     430        EXAMPLES::
     431
    386432            sage: from sage.server.notebook.interact import InputBox, InteractCanvas
    387433            sage: B = InputBox('x',2)
    388434            sage: canvas1 = InteractCanvas([B], 3)
     
    398444
    399445    def canvas(self):
    400446        """
    401         Returns the InteractCanvas associated to this element.  If no
    402         canvas has been set (via the set_canvas method), then this
    403         will return a ValueError.
     447        Returns the ``InteractCanvas`` associated to this element.  If
     448        no canvas has been set (via the ``set_canvas`` method), then
     449        this will return a ``ValueError``.
    404450
    405         EXAMPLES:
     451        EXAMPLES::
     452
    406453            sage: from sage.server.notebook.interact import InputBox, InteractCanvas
    407454            sage: B = InputBox('x',2)
    408455            sage: canvas1 = InteractCanvas([B], 3)
     
    420467class InteractControl(InteractElement):
    421468    def __init__(self, var, default_value, label=None):
    422469        """
    423         Abstract base class for interact controls.  These are controls
    424         that are used in a specific interact.  They have internal
    425         state information about the specific function being interactd,
     470        Abstract base class for ``interact`` controls.  These are controls
     471        that are used in a specific ``interact``.  They have internal
     472        state information about the specific function being interacted,
    426473        etc.
    427474       
    428475        INPUT:
    429              var -- string; name of variable that this control interacts
    430              default_value -- the default value of the variable
    431                               corresponding to this control.
    432              label -- string (default: None) label of this control; if None
    433                       then defaults to var.
    434476
    435         EXAMPLES:
     477             ``var`` -- string; name of variable that this control
     478             interacts
     479
     480             ``default_value`` -- the default value of the variable
     481             corresponding to this control.
     482
     483             ``label`` -- string (default: ``None``) label of this
     484             control; if ``None`` then defaults to ``var``.
     485
     486        EXAMPLES::
     487
    436488            sage: from sage.server.notebook.interact import InteractControl
    437489            sage: InteractControl('x', default_value=5)
    438490            A InteractControl (abstract base class)
     
    450502
    451503    def __repr__(self):
    452504        """
    453         String representation of interact control.
     505        String representation of ``interact`` control.
    454506
    455         EXAMPLES:
     507        EXAMPLES::
     508
    456509            sage: from sage.server.notebook.interact import InteractControl
    457510            sage: InteractControl('x', default_value=5).__repr__()
    458511            'A InteractControl (abstract base class)'
     
    461514
    462515    def value_js(self):
    463516        """
    464         Javascript that when evaluated gives the current value of this
     517        JavaScript that when evaluated gives the current value of this
    465518        control.  This should be redefined in a derived class.
    466519
    467520        OUTPUT:
    468             string -- defaults to NULL -- this should be redefined.
    469521
    470         EXAMPLES:
     522            string -- defaults to ``'NULL'`` -- this should be redefined.
     523
     524        EXAMPLES::
     525
    471526            sage: sage.server.notebook.interact.InteractControl('x', default_value=5).value_js()
    472527            'NULL'       
    473528        """
     
    475530
    476531    def label(self):
    477532        """
    478         Return the text label of this interact control.
     533        Return the text label of this ``interact`` control.
    479534
    480         EXAMPLES:
     535        EXAMPLES::
     536
    481537            sage: from sage.server.notebook.interact import InteractControl
    482538            sage: InteractControl('x', default_value=5, label='the x value').label()
    483539            'the x value'       
     
    487543    def default_value(self):
    488544        """
    489545        Return the default value of the variable corresponding to this
    490         interact control.
     546        ``interact`` control.
    491547
    492548        OUTPUT:
     549
    493550            object
    494551
    495         EXAMPLES:
     552        EXAMPLES::
     553
    496554            sage: from sage.server.notebook.interact import InteractControl
    497555            sage: InteractControl('x', 19/3).default_value()
    498556            19/3
     
    502560    def html_escaped_default_value(self):
    503561        """
    504562        Returns the HTML escaped default value of the variable
    505         corresponding to this interact control.  Note that any
    506         HTML that uses quotes around this should use double
    507         quotes and not single quotes.
     563        corresponding to this ``interact`` control.  Note that any
     564        HTML that uses quotes around this should use double quotes and
     565        not single quotes.
    508566
    509         EXAMPLES:
     567        EXAMPLES::
     568
    510569            sage: from sage.server.notebook.interact import InteractControl
    511570            sage: InteractControl('x', '"cool"').html_escaped_default_value()
    512571            '&quot;cool&quot;'
     
    528587        called to adapt the values of this control to Python.
    529588
    530589        OUTPUT:
     590
    531591            an integer
    532592
    533         EXAMPLES:
     593        EXAMPLES::
     594
    534595            sage: from sage.server.notebook.interact import InteractControl
    535596            sage: InteractControl('x', 19/3).adapt_number()       # random -- depends on call order
    536597            2
     
    543604        by this control.
    544605
    545606        INPUT:
    546             value -- the string the user typed in
    547             globs -- the globals interpreter variables, e.g.,
    548                      globals(), which is useful for evaling value.
     607
     608            ``value`` -- the string the user typed in
     609
     610            ``globs`` -- the globals interpreter variables, e.g.,
     611            ``globals()``, which is useful for evaling value.
    549612
    550613        OUTPUT:
     614
    551615            object
    552616
    553         EXAMPLES:
     617        EXAMPLES::
     618
    554619            sage: sage.server.notebook.interact.InteractControl('x', 1)._adaptor('2/3', globals())
    555620            2/3       
    556621        """
     
    558623       
    559624    def interact(self, *args):
    560625        """
    561         Return a string that when evaluated in Javascript calls the
    562         javascript interact function with appropriate inputs for
     626        Return a string that when evaluated in JavaScript calls the
     627        JavaScript ``interact`` function with appropriate inputs for
    563628        this control.
    564629
    565630        This method will check to see if there is a canvas attached to
     
    569634        automatically update.
    570635
    571636        OUTPUT:
    572             string -- that is meant to be evaluated in Javascript
    573637
    574         EXAMPLES:
     638            string -- that is meant to be evaluated in JavaScript
     639
     640        EXAMPLES::
     641
    575642            sage: sage.server.notebook.interact.InteractControl('x', 1).interact()
    576643            'interact(..., "sage.server.notebook.interact.update(..., \\"x\\", ..., sage.server.notebook.interact.standard_b64decode(\\""+encode64(NULL)+"\\"), globals());sage.server.notebook.interact.recompute(0)")'
    577644        """
     
    599666        Return the name of the variable that this control interacts.
    600667
    601668        OUTPUT:
     669
    602670            string -- name of a variable as a string.
    603671
    604         EXAMPLES:
     672        EXAMPLES::
     673
    605674            sage: sage.server.notebook.interact.InteractControl('theta', 1).var()
    606675            'theta'       
    607676        """
     
    609678
    610679    def cell_id(self):
    611680        """
    612         Return the id of the cell that contains this interact control.
     681        Return the id of the cell that contains this ``interact`` control.
    613682
    614683        OUTPUT:
     684
    615685            integer -- id of cell that this control interacts
    616686
    617687        EXAMPLES:
    618         The output below should equal the ID of the current cell.
     688
     689        The output below should equal the id of the current cell::
     690
    619691            sage: sage.server.notebook.interact.InteractControl('theta', 1).cell_id()
    620692            0
    621693        """
     
    624696class InputBox(InteractControl):
    625697    def __init__(self, var, default_value, label=None, type=None, width = 80):
    626698        """
    627         An input box interact control.
     699        An input box ``interact`` control.
    628700
    629         InputBox(var, default_value, label, type)
     701        ``InputBox(var, default_value, label, type)``
    630702
    631         EXAMPLES:
     703        EXAMPLES::
     704
    632705            sage: sage.server.notebook.interact.InputBox('theta', 1, 'theta')
    633706            An InputBox interactive control with theta=1 and label 'theta'
    634707            sage: sage.server.notebook.interact.InputBox('theta', 1, 'theta', int)
     
    640713       
    641714    def __repr__(self):
    642715        """
    643         String representation of an InputBox interactive control.
     716        String representation of an ``InputBox`` interactive control.
    644717
    645         EXAMPLES:
     718        EXAMPLES::
     719
    646720            sage: sage.server.notebook.interact.InputBox('theta', 1).__repr__()
    647721            "An InputBox interactive control with theta=1 and label 'theta'"
    648722        """
     
    655729        element selected by this control.
    656730
    657731        INPUT:
    658             value -- text entered by user
    659             globs -- the globals interpreter variables (not used here).
     732
     733            ``value`` -- text entered by user
     734            ``globs`` -- the ``globals`` interpreter variables (not used here).
    660735
    661736        OUTPUT:
     737
    662738            object
    663739
    664         EXAMPLES:
     740        EXAMPLES::
     741
    665742            sage: sage.server.notebook.interact.InputBox('theta', Color('red'), type=Color)._adaptor('#aaaaaa',globals())
    666743            RGB color (0.6640625, 0.6640625, 0.6640625)
    667744        """
     
    676753
    677754    def value_js(self):
    678755        """
    679         Return javascript string that will give the value of this
     756        Return JavaScript string that will give the value of this
    680757        control element.
    681758
    682759        OUTPUT:
    683              string -- javascript
    684760
    685         EXAMPLES:
     761             string -- JavaScript
     762
     763        EXAMPLES::
     764
    686765            sage: sage.server.notebook.interact.InputBox('theta', 1).value_js()
    687766            'this.value'
    688767        """
     
    696775        Render this control as a string.
    697776
    698777        OUTPUT:
    699              string -- html format
    700778
    701         EXAMPLES:
     779             string -- HTML format
     780
     781        EXAMPLES::
     782
    702783            sage: sage.server.notebook.interact.InputBox('theta', 1).render()
    703784            '<input type=\'text\' value="1" size=80 onchange=\'interact(0, "sage.server.notebook.interact.update(0, \\"theta\\", ..., sage.server.notebook.interact.standard_b64decode(\\""+encode64(this.value)+"\\"), globals());sage.server.notebook.interact.recompute(0)")\'></input>'
    704785        """
     
    715796class ColorInput(InputBox):
    716797    def value_js(self, n):
    717798        """
    718         Return javascript that evaluates to value of this control.
     799        Return JavaScript that evaluates to value of this control.
    719800
    720801        INPUT:
    721             n -- integer, either 0 or 1.
    722802
    723         If n is 0 return code for evaluation by the actual color control.
    724         If n is 1, return code for the text area that displays the current color.
     803            ``n`` -- integer, either ``0`` or ``1``.
    725804
    726         EXAMPLES:
     805        If ``n`` is ``0`` return code for evaluation by the actual color
     806        control.  If ``n`` is ``1``, return code for the text area that
     807        displays the current color.
     808
     809        EXAMPLES::
     810
    727811            sage: C = sage.server.notebook.interact.ColorInput('c', Color('red'))
    728812            sage: C.value_js(0)
    729813            'color'
     
    737821
    738822    def render(self):
    739823        """
    740         Render this color input box to html.
     824        Render this color input box to HTML.
    741825
    742         EXAMPLES:
     826        EXAMPLES::
     827
    743828            sage: sage.server.notebook.interact.ColorInput('c', Color('red')).render()
    744829            '<table>...'
    745830        """
     
    754839        """
    755840        A grid interact control.
    756841
    757         INPUT
    758             var -- the variable
    759             rows -- the number of rows
    760             columns -- the number of columns
    761             default_value -- if this is a scalar, it is put in every
    762                 cell; if it is a list, it is filled into the cells row by
    763                 row; if it is a nested list, then it is filled into the
    764                 cells according to the nesting structure.
    765             label -- the label for the control
    766             to_value -- a function which is applied to the nested list
    767                 from user input when assigning the variable
    768             width -- the width of the input boxes
     842        INPUT:
    769843
    770         EXAMPLES:
     844            ``var`` -- the variable
     845
     846            ``rows`` -- the number of rows
     847
     848            ``columns`` -- the number of columns
     849
     850            ``default_value`` -- if this is a scalar, it is put in
     851            every cell; if it is a list, it is filled into the cells
     852            row by row; if it is a nested list, then it is filled into
     853            the cells according to the nesting structure.
     854
     855            ``label`` -- the label for the control
     856
     857            ``to_value`` -- a function which is applied to the nested
     858            list from user input when assigning the variable
     859
     860            ``width`` -- the width of the input boxes
     861
     862        EXAMPLES::
     863
    771864            sage: sage.server.notebook.interact.InputGrid('M', 2,2, default_value = 0, label='M')
    772865            A 2 x 2 InputGrid interactive control with M=[[0, 0], [0, 0]] and label 'M'
    773866            sage: sage.server.notebook.interact.InputGrid('M', 2,2, default_value = [[1,2],[3,4]], label='M')
     
    795888
    796889    def __repr__(self):
    797890        """
    798         String representation of an InputGrid interactive control.
     891        String representation of an ``InputGrid`` interactive control.
    799892
    800         EXAMPLES:
     893        EXAMPLES::
     894
    801895            sage: sage.server.notebook.interact.InputGrid('M', 2,2).__repr__()
    802896            "A 2 x 2 InputGrid interactive control with M=[[None, None], [None, None]] and label 'M'"
    803897        """
     
    812906        element selected by this control.
    813907
    814908        INPUT:
    815             value -- text entered by user
    816             globs -- the globals interpreter variables (not used here).
     909
     910            ``value`` -- text entered by user
     911
     912            ``globs`` -- the ``globals`` interpreter variables (not
     913            used here).
    817914
    818915        OUTPUT:
     916
    819917            object
    820918
    821         EXAMPLES:
     919        EXAMPLES::
     920
    822921            sage: sage.server.notebook.interact.InputGrid('M', 1,3, default_value=[[1,2,3]], to_value=lambda x: vector(flatten(x)))._adaptor("[[4,5,6]]", globals())
    823922            (4, 5, 6)
    824923        """
     
    827926
    828927    def value_js(self):
    829928        """
    830         Return javascript string that will give the value of this
     929        Return JavaScript string that will give the value of this
    831930        control element.
    832931
    833932        OUTPUT:
    834              string -- javascript
    835933
    836         EXAMPLES:
     934             string -- JavaScript
     935
     936        EXAMPLES::
     937
    837938            sage: sage.server.notebook.interact.InputGrid('M', 2,2).value_js()
    838939            ' "[["+jQuery(this).parents("table").eq(0).find("tr").map(function(){return jQuery(this).find("input").map(function() {return jQuery(this).val();}).get().join(",");}).get().join("],[")+"]]" '
    839940        """
     
    848949        Render this control as a string.
    849950
    850951        OUTPUT:
    851              string -- html format
    852952
    853         EXAMPLES:
     953             string -- HTML format
     954
     955        EXAMPLES::
     956
    854957            sage: sage.server.notebook.interact.InputGrid('M', 1,2).render()
    855958            '<table><tr><td><input type=\'text\' value=\'None\' ...
    856959
     
    874977        A drop down menu or a button bar that when pressed sets a
    875978        variable to a given value.
    876979
    877         Selector(var, values, label=None, nrows=None, ncols=None)
     980        ``Selector(var, values, label=None, nrows=None, ncols=None)``
    878981
    879982        INPUT:
    880             var   -- string; variable name
    881             values-- list; button values
    882             label -- string (default: None) label off to the left for this button group
    883             default -- integer (default: 0) position of default value in values list.
    884             nrows -- integer (default: None) number of rows
    885             ncols -- integer (default: None) number of columns
    886             width -- integer (default: None) width of all the buttons
    887             buttons -- bool (default: False) if True use buttons instead of dropdown
    888983
    889         EXAMPLES:
     984            ``var`` -- string; variable name
     985
     986            ``values`` -- list; button values
     987
     988            ``label`` -- string (default: ``None``) label off to the
     989            left for this button group
     990
     991            ``default`` -- integer (default: ``0``) position of default
     992            value in values list.
     993
     994            ``nrows`` -- integer (default: ``None``) number of rows
     995
     996            ``ncols`` -- integer (default: ``None``) number of columns
     997
     998            ``width`` -- integer (default: ``None``) width of all the buttons
     999
     1000            ``buttons`` -- bool (default: ``False``) if ``True`` use
     1001            buttons instead of dropdown
     1002
     1003        EXAMPLES::
     1004
    8901005            sage: sage.server.notebook.interact.Selector('x', [1..5], 'alpha', default=2)
    8911006            Selector with 5 options for variable 'x'
    8921007            sage: sage.server.notebook.interact.Selector('x', [1..4], 'alpha', default=2, nrows=2, ncols=2, width=10, buttons=True)
     
    9371052       
    9381053    def __repr__(self):
    9391054        """
    940         String representation of a Selector interactive control.
     1055        String representation of a ``Selector`` interactive control.
    9411056
    942         EXAMPLES:
     1057        EXAMPLES::
     1058
    9431059            sage: sage.server.notebook.interact.Selector('x', [1..5]).__repr__()
    9441060            "Selector with 5 options for variable 'x'"       
    9451061        """
     
    9531069        it to be the value that we associate with that button.
    9541070
    9551071        INPUT:
    956             value -- value sent in via javascript
    957             globs -- the globals interpreter variables (not used here).
     1072
     1073            ``value` -- value sent in via JavaScript
     1074
     1075            ``globs`` -- the ``globals`` interpreter variables (not
     1076            used here).
    9581077
    9591078        OUTPUT:
     1079
    9601080            object
    9611081
    962         EXAMPLES:
     1082        EXAMPLES::
     1083
    9631084            sage: S = sage.server.notebook.interact.Selector('x', ['first',x^3+5])
    9641085            sage: S._adaptor(0,globals())
    9651086            'first'
     
    9701091
    9711092    def use_buttons(self):
    9721093        """
    973         Whether or not to use buttons instead of a drop
    974         down menu for this select list.
     1094        Whether or not to use buttons instead of a drop down menu for
     1095        this select list.
    9751096
    9761097        OUTPUT:
     1098
    9771099            bool
    9781100
    979         EXAMPLES:
     1101        EXAMPLES::
     1102
    9801103            sage: sage.server.notebook.interact.Selector('x', [1..5]).use_buttons()
    9811104            False
    9821105            sage: sage.server.notebook.interact.Selector('x', [1..5], buttons=True).use_buttons()
     
    9861109
    9871110    def value_js(self):
    9881111        """
    989         Return javascript string that will give the value of this
     1112        Return JavaScript string that will give the value of this
    9901113        control element.
    9911114
    9921115        OUTPUT:
    993              string -- javascript
    9941116
    995         EXAMPLES:
     1117             string -- JavaScript
     1118
     1119        EXAMPLES::
     1120
    9961121            sage: sage.server.notebook.interact.Selector('x', [1..5]).value_js()
    9971122            'this.options[this.selectedIndex].value'
    9981123            sage: sage.server.notebook.interact.Selector('x', [1..5], buttons=True).value_js()
     
    10091134        Render this control as a string.
    10101135
    10111136        OUTPUT:
    1012              string -- html format
    10131137
    1014         EXAMPLES:
     1138             string -- HTML format
     1139
     1140        EXAMPLES::
     1141
    10151142            sage: sage.server.notebook.interact.Selector('x', [1..5]).render()
    10161143            '<select...</select>'
    10171144            sage: sage.server.notebook.interact.Selector('x', [1..5], buttons=True).render()
     
    10661193class SliderGeneric(InteractControl):
    10671194    def __init__(self, var, values, default_value, label=None, display_value=True):
    10681195        """
    1069         An abstract slider interact control that takes on the given list of
    1070         values.
     1196        An abstract slider ``interact`` control that takes on the
     1197        given list of values.
    10711198
    10721199        INPUT:
    1073             var -- string; name of variable being interactd
    1074             values -- list; a list of the values that the slider will take on
    1075             default_value -- default valueoif slider.
    1076             label -- alternative label to the left of the slider,
    1077                      instead of the variable.
    1078             display_value -- boolean, whether to display the current value
    1079                              on the slider
    10801200
    1081         EXAMPLES:
     1201            ``var`` -- string; name of variable being interacted
     1202
     1203            ``values`` -- list; a list of the values that the slider
     1204            will take on
     1205
     1206            ``default_value`` -- default value of the slider.
     1207
     1208            ``label`` -- alternative label to the left of the slider,
     1209            instead of the variable.
     1210
     1211            ``display_value`` -- boolean, whether to display the
     1212            current value on the slider
     1213
     1214        EXAMPLES::
     1215
    10821216            sage: sage.server.notebook.interact.SliderGeneric('x', [1..5], 2, 'alpha')
    10831217            Abstract Slider Interact Control: alpha [1--|2|---5]
    10841218        """
     
    10901224        """
    10911225        Return string representation of this slider control.
    10921226
    1093         EXAMPLES:
     1227        EXAMPLES::
     1228
    10941229            sage: sage.server.notebook.interact.SliderGeneric('x', [1..5], 2, 'alpha').__repr__()
    10951230            'Abstract Slider Interact Control: alpha [1--|2|---5]'
    10961231        """
     
    11031238        Return list of values the slider acts on.
    11041239       
    11051240        OUTPUT:
     1241
    11061242            list
    11071243           
    1108         EXAMPLES:
     1244        EXAMPLES::
     1245
    11091246            sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha').values()
    11101247            [1, 2, 3, 4, 5]
    11111248        """
     
    11161253        Returns whether to display the value on the slider.
    11171254       
    11181255        OUTPUT:
    1119             boolean
     1256
     1257            bool
    11201258       
    1121         EXAMPLES:
     1259        EXAMPLES::
     1260
    11221261            sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha').display_value()
    11231262            True
    11241263        """
     
    11261265
    11271266    def values_js(self):
    11281267        """
    1129         Returns Javascript array representation of values or null if display_value is False
     1268        Returns JavaScript array representation of values or ``'null'`` if
     1269        ``display_value=False``
    11301270
    11311271        OUTPUT:
     1272
    11321273            string
    11331274       
    1134         EXAMPLES:
     1275        EXAMPLES::
     1276
    11351277            sage: sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha').values_js()
    11361278            '["1","2","3","4","5"]'
    11371279            sage: sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha', False).values_js()
     
    11521294class Slider(SliderGeneric):
    11531295    def __init__(self, var, values, default_position, label=None, display_value=True):
    11541296        """
    1155         A slider interact control that takes on the given list of
     1297        A slider ``interact`` control that takes on the given list of
    11561298        values.
    11571299
    11581300        INPUT:
    1159             var -- string; name of variable being interactd
    1160             values -- list; a list of the values that the slider will take on
    1161             default_position -- int; default location that the slider is set to.
    1162             label -- alternative label to the left of the slider,
    1163                      instead of the variable.
    1164             display_value -- boolean, whether to display the current value right
    1165                              of the slider
    11661301
    1167         EXAMPLES:
     1302            ``var`` -- string; name of variable being interacted
     1303
     1304            ``values`` -- list; a list of the values that the slider
     1305            will take on
     1306
     1307            ``default_position`` -- int; default location that the
     1308            slider is set to.
     1309
     1310            ``label`` -- alternative label to the left of the slider,
     1311            instead of the variable.
     1312
     1313            ``display_value`` -- boolean, whether to display the
     1314            current value right of the slider
     1315
     1316        EXAMPLES::
     1317
    11681318            sage: sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha')
    11691319            Slider Interact Control: alpha [1--|3|---5]
    11701320        """
     
    11751325        """
    11761326        Return string representation of this slider control.
    11771327
    1178         EXAMPLES:
     1328        EXAMPLES::
     1329
    11791330            sage: sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha').__repr__()
    11801331            'Slider Interact Control: alpha [1--|3|---5]'
    11811332        """
     
    11871338        """
    11881339        Return the default position (as an integer) of the slider.
    11891340
    1190         EXAMPLES:
     1341        EXAMPLES::
     1342
    11911343            sage: sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha').default_position()
    11921344            2
    11931345        """
     
    11951347
    11961348    def value_js(self):
    11971349        """
    1198         Return javascript string that will give the
    1199         value of this control element.
     1350        Return JavaScript string that will give the value of this
     1351        control element.
    12001352
    12011353        OUTPUT:
    1202              string -- javascript
    12031354
    1204         EXAMPLES:
     1355             string -- JavaScript
     1356
     1357        EXAMPLES::
     1358
    12051359            sage: sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha').value_js()
    12061360            'position'
    12071361        """
     
    12131367        element selected by this control.
    12141368
    12151369        INPUT:
    1216             position -- position of the slider
    1217             globs -- the globals interpreter variables (not used here).
     1370
     1371            ``position`` -- position of the slider
     1372
     1373            ``globs`` -- the ``globals`` interpreter variables (not used here).
    12181374
    12191375        OUTPUT:
     1376
    12201377            object
    12211378
    1222         EXAMPLES:
     1379        EXAMPLES::
     1380
    12231381            sage: sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha')._adaptor(2,globals())
    12241382            3
    12251383        """
     
    12331391        Render this control as an HTML string.
    12341392
    12351393        OUTPUT:
    1236              string -- html format
    12371394
    1238         EXAMPLES:
     1395             string -- HTML format
     1396
     1397        EXAMPLES::
     1398
    12391399            sage: sage.server.notebook.interact.Slider('x', [1..5], 2, 'alpha').render()
    12401400            '<table>...<div ...var values = ["1","2","3","4","5"];...'
    12411401
     
    12511411class RangeSlider(SliderGeneric):
    12521412    def __init__(self, var, values, default_position, label=None, display_value=True):
    12531413        """
    1254         A range slider interact control that takes on the given list of
    1255         values.
     1414        A range slider ``interact`` control that takes on the given
     1415        list of values.
    12561416
    12571417        INPUT:
    1258             var -- string; name of variable being interactd
    1259             values -- list; a list of the values that the slider will take on
    1260             default_position -- (int,int); default location that the slider is set to.
    1261             label -- alternative label to the left of the slider,
    1262                      instead of the variable.
    1263             display_value -- boolean, whether to display the current value below
    1264                              the slider
    12651418
    1266         EXAMPLES:
     1419            ``var`` -- string; name of variable being interacted
     1420
     1421            ``values`` -- list; a list of the values that the slider
     1422            will take on
     1423
     1424            ``default_position`` -- (int,int); default location that
     1425            the slider is set to.
     1426
     1427            ``label`` -- alternative label to the left of the slider,
     1428            instead of the variable.
     1429
     1430            ``display_value`` -- boolean, whether to display the
     1431            current value below the slider
     1432
     1433        EXAMPLES::
     1434
    12671435            sage: sage.server.notebook.interact.RangeSlider('x', [1..5], (2,3), 'alpha')
    12681436            Range Slider Interact Control: alpha [1--|3==4|---5]
    12691437        """
     
    12741442        """
    12751443        Return string representation of this slider control.
    12761444
    1277         EXAMPLES:
     1445        EXAMPLES::
     1446
    12781447            sage: sage.server.notebook.interact.RangeSlider('x', [1..5], (2,3), 'alpha').__repr__()
    12791448            'Range Slider Interact Control: alpha [1--|3==4|---5]'
    12801449        """
     
    12861455        """
    12871456        Return the default position (as an integer) of the slider.
    12881457
    1289         EXAMPLES:
     1458        EXAMPLES::
     1459
    12901460            sage: sage.server.notebook.interact.RangeSlider('x', [1..5], (2,3), 'alpha').default_position()
    12911461            (2, 3)
    12921462        """
     
    12941464
    12951465    def value_js(self):
    12961466        """
    1297         Return javascript string that will give the
    1298         value of this control element.
     1467        Return JavaScript string that will give the value of this
     1468        control element.
    12991469
    13001470        OUTPUT:
    1301              string -- javascript
    13021471
    1303         EXAMPLES:
     1472             string -- JavaScript
     1473
     1474        EXAMPLES::
     1475
    13041476            sage: sage.server.notebook.interact.RangeSlider('x', [1..5], (2,3), 'alpha').value_js()
    13051477            "pos[0]+' '+pos[1]"
    13061478        """
     
    13121484        element selected by this control.
    13131485
    13141486        INPUT:
    1315             position -- position of the slider
    1316             globs -- the globals interpreter variables (not used here).
     1487
     1488            ``position`` -- position of the slider
     1489
     1490            ``globs` -- the ``globals`` interpreter variables (not
     1491            used here).
    13171492
    13181493        OUTPUT:
     1494
    13191495            object
    13201496
    1321         EXAMPLES:
     1497        EXAMPLES::
     1498
    13221499            sage: sage.server.notebook.interact.RangeSlider('x', [1..5], (2,3), 'alpha')._adaptor("2 3",globals())
    13231500            (3, 4)
    13241501        """
     
    13321509        Render this control as an HTML string.
    13331510
    13341511        OUTPUT:
    1335              string -- html format
    13361512
    1337         EXAMPLES:
     1513             string -- HTML format
     1514
     1515        EXAMPLES::
     1516
    13381517            sage: sage.server.notebook.interact.RangeSlider('x', [1..5], (2,3), 'alpha').render()
    13391518            '<table>...<div ...var values = ["1","2","3","4","5"];...'
    13401519
     
    13511530class TextControl(InteractControl):
    13521531    def __init__(self, var, data):
    13531532        """
    1354         A text field interact control
     1533        A text field ``interact`` control
    13551534
    13561535        INPUT:
    1357             data -- the HTML value of the text field
    13581536
    1359         EXAMPLES:
     1537            ``data`` -- the HTML value of the text field
     1538
     1539        EXAMPLES::
     1540
    13601541            sage: sage.server.notebook.interact.TextControl('x', 'something')
    13611542            Text Interact Control: something
    13621543        """
     
    13671548        """
    13681549        Return string representation of this control.
    13691550
    1370         EXAMPLES:
     1551        EXAMPLES::
     1552
    13711553            sage: sage.server.notebook.interact.TextControl('x', 'something').__repr__()
    13721554            'Text Interact Control: something'
    13731555        """
     
    13781560        Render this control as an HTML string.
    13791561
    13801562        OUTPUT:
    1381              string -- html format
    13821563
    1383         EXAMPLES:
     1564             string -- HTML format
     1565
     1566        EXAMPLES::
     1567
    13841568            sage: sage.server.notebook.interact.TextControl('x', 'something').render()
    13851569            '<div ...>something</div>'
    13861570        """
     
    14151599        """
    14161600        Print representation of an interactive canvas.
    14171601
    1418         EXAMPLES:
     1602        EXAMPLES::
     1603
    14191604            sage: B = sage.server.notebook.interact.InputBox('x',2)
    14201605            sage: sage.server.notebook.interact.InteractCanvas([B], 3).__repr__()
    14211606            'Interactive canvas in cell 3 with 1 controls'
     
    14241609            self.__cell_id, len(self.__controls))
    14251610
    14261611    def is_auto_update(self):
    1427         """
    1428         Returns True if any change of the values for the controls on
    1429         this canvas should cause an update.  If auto_update=False was
     1612        r"""
     1613        Returns ``True`` if any change of the values for the controls on
     1614        this canvas should cause an update.  If ``auto_update=False`` was
    14301615        not specified in the constructor for this canvas, then this
    1431         will default to True.
     1616        will default to ``True``.
    14321617
    1433         EXAMPLES:
     1618        EXAMPLES::
     1619
    14341620            sage: B = sage.server.notebook.interact.InputBox('x',2)
    14351621            sage: canvas = sage.server.notebook.interact.InteractCanvas([B], 3)
    14361622            sage: canvas.is_auto_update()
     
    14421628        return self.__options.get('auto_update', True)
    14431629
    14441630    def cell_id(self):
    1445         """
    1446         Returns the cell id associated to this InteractCanvas.
     1631        r"""
     1632        Returns the cell id associated to this ``InteractCanvas``.
    14471633
    1448         EXAMPLES:
     1634        EXAMPLES::
     1635
    14491636            sage: B = sage.server.notebook.interact.InputBox('x',2)
    14501637            sage: canvas = sage.server.notebook.interact.InteractCanvas([B], 3)
    14511638            sage: canvas.cell_id()
     
    14591646
    14601647        WARNING: Returns a reference to a mutable list.
    14611648
    1462         EXAMPLES:
     1649        EXAMPLES::
     1650
    14631651            sage: B = sage.server.notebook.interact.InputBox('x',2)
    14641652            sage: sage.server.notebook.interact.InteractCanvas([B], 3).controls()
    14651653            [An InputBox interactive control with x=2 and label 'x']
     
    14701658        """
    14711659        Return the cell id that contains this interactive canvas.
    14721660
    1473         EXAMPLES:
     1661        EXAMPLES::
     1662
    14741663            sage: B = sage.server.notebook.interact.InputBox('x',2)
    14751664            sage: sage.server.notebook.interact.InteractCanvas([B], 3).cell_id()
    14761665            3
     
    14791668
    14801669    def render_output(self):
    14811670        """
    1482         Render in text (html) form the output portion of the interact canvas.
     1671        Render in text (HTML) form the output portion of the
     1672        ``interact`` canvas.
    14831673
    14841674        The output contains two special tags, <?TEXT> and <?HTML>,
    1485         which get replaced at runtime by the text and html parts
     1675        which get replaced at runtime by the text and HTML parts
    14861676        of the output of running the function.
    14871677
    14881678        OUTPUT:
    1489             string -- html
    14901679
    1491         EXAMPLES:
     1680            string -- HTML
     1681
     1682        EXAMPLES::
     1683
    14921684            sage: B = sage.server.notebook.interact.InputBox('x',2)
    14931685            sage: sage.server.notebook.interact.InteractCanvas([B], 3).render_output()
    14941686            "<div ...</div>"
     
    15011693
    15021694    def render_controls(self):
    15031695        """
    1504         Render in text (html) form all the input controls.
     1696        Render in text (HTML) form all the input controls.
    15051697
    15061698        OUTPUT:
    1507             string -- html
    15081699
    1509         EXAMPLES:
     1700            string -- HTML
     1701
     1702        EXAMPLES::
     1703
    15101704            sage: B = sage.server.notebook.interact.InputBox('x',2)
    15111705            sage: sage.server.notebook.interact.InteractCanvas([B], 3).render_controls()
    15121706            '<table>...'
     
    15231717    def wrap_in_outside_frame(self, inside):
    15241718        """
    15251719        Return the entire HTML for the interactive canvas, obtained by
    1526         wrapping all the inside html of the canvas in a div and a
     1720        wrapping all the inside HTML of the canvas in a div and a
    15271721        table.
    15281722
    15291723        INPUT:
    1530             inside -- string (of HTML)
     1724
     1725            ``inside`` -- string (of HTML)
    15311726
    15321727        OUTPUT:
     1728
    15331729            string of HTML
    15341730           
    1535         EXAMPLES:
     1731        EXAMPLES::
     1732
    15361733            sage: B = sage.server.notebook.interact.InputBox('x',2)
    15371734            sage: sage.server.notebook.interact.InteractCanvas([B], 3).wrap_in_outside_frame('<!--inside-->')
    15381735            "<!--notruncate--><div padding=6 id='div-interact-3'> ...</div>\n                 "
     
    15531750
    15541751    def render(self):
    15551752        """
    1556         Render in text (html) the entire interact canvas.
     1753        Render in text (HTML) the entire ``interact`` canvas.
    15571754
    15581755        OUTPUT:
    1559             string -- html
     1756
     1757            string -- HTML
    15601758           
    1561         EXAMPLES:
     1759        EXAMPLES::
     1760
    15621761            sage: B = sage.server.notebook.interact.InputBox('x',2)
    15631762            sage: sage.server.notebook.interact.InteractCanvas([B], 3).render()
    15641763            '<!--notruncate--><div padding=6 id=\'div-interact-3\'> ...</div>\n                 '
     
    15701769class JavascriptCodeButton(InteractElement):
    15711770    def __init__(self, label, code):
    15721771        """
    1573         This interact element displays a button which when clicked
    1574         executes Javascript code in the notebook.
     1772        This ``interact`` element displays a button which when clicked
     1773        executes JavaScript code in the notebook.
    15751774
    1576         EXAMPLES:
     1775        EXAMPLES::
     1776
    15771777            sage: b = sage.server.notebook.interact.JavascriptCodeButton('Push me', 'alert("2")')
    15781778        """
    15791779        self.__label = label
     
    15841784        r"""
    15851785        Returns the HTML to display this button.
    15861786
    1587         EXAMPLES:
     1787        EXAMPLES::
     1788
    15881789            sage: b = sage.server.notebook.interact.JavascriptCodeButton('Push me', 'alert("2")')
    15891790            sage: b.render()
    15901791            '<input type="button" value="Push me" onclick=\'alert("2")\'>\n'
     
    15951796class UpdateButton(JavascriptCodeButton):
    15961797    def __init__(self, cell_id):
    15971798        r"""
    1598         This interact element creates a button which when clicked
    1599         causes the interact function in the cell cell_id to be
     1799        This ``interact`` element creates a button which when clicked
     1800        causes the ``interact`` function in the cell ``cell_id`` to be
    16001801        recomputed with the current values of the variables.
    16011802
    1602         EXAMPLES:
     1803        EXAMPLES::
     1804
    16031805            sage: b = sage.server.notebook.interact.UpdateButton(0)
    16041806            sage: b.render()
    16051807            '<input type="button" value="Update" onclick=\'interact(0, "sage.server.notebook.interact.recompute(0)")\'>\n'
     
    16811883        <html>...
    16821884
    16831885    DEFAULTS:
     1886
    16841887    Defaults for the variables of the input function determine
    1685     interactive controls.  The standard controls are \code{input_box},
    1686     \code{slider}, \code{range_slider}, \code{checkbox}, \code{selector},
    1687     \code{input_grid}.  There is also a color selector and text control
     1888    interactive controls.  The standard controls are ``input_box``,
     1889    ``slider``, ``range_slider``, ``checkbox``, ``selector``, and
     1890    ``input_grid``.  There is also a color selector and text control
    16881891    (see defaults below).
     1892
    16891893   
    1690     \begin{itemize}
    1691         \item u = input_box(default=None, label=None, type=None)
    1692                          -- input box with given default; use type=str to
    1693                             get input as an arbitrary string
    1694         \item u = slider(vmin, vmax=None,step_size=1,default=None,label=None)
    1695                          -- slider with given list of possible values; vmin can be a list
    1696         \item u = range_slider(vmin, vmax=None,step_size=1,default=None,label=None)
    1697                          -- range slider with given list of possible values;
    1698                             vmin can be a list
    1699         \item u = checkbox(default=True, label=None)
    1700                          -- a checkbox
    1701         \item u = selector(values, label=None, nrows=None, ncols=None, buttons=False)                 
    1702                          -- a dropdown menu or buttons (get buttons if nrows,
    1703                             ncols, or buttons is set, otherwise a dropdown menu)
    1704         \item u = input_grid(nrows, ncols, default=None, label=None,
    1705                              to_value=lambda x:x, width=4)
    1706                          -- an editable grid of objects (a matrix or array)
    1707         \item u = text_control(value='')
    1708                          -- a block of text
    1709     \end{itemize}
     1894        * ``u = input_box(default=None, label=None, type=None)`` --
     1895          input box with given ``default``; use ``type=str`` to get
     1896          input as an arbitrary string
     1897
     1898
     1899        * ``u = slider(vmin, vmax=None, step_size=1, default=None,
     1900          label=None)`` -- slider with given list of possible values;
     1901          ``vmin`` can be a list
     1902
     1903
     1904        * ``u = range_slider(vmin, vmax=None, step_size=1,
     1905          default=None, label=None)`` -- range slider with given list
     1906          of possible values; ``vmin`` can be a list
     1907
     1908
     1909        * ``u = checkbox(default=True, label=None)`` -- a checkbox
     1910
     1911
     1912        * ``u = selector(values, label=None, nrows=None, ncols=None,
     1913          buttons=False)`` -- a dropdown menu or buttons (get buttons
     1914          if ``nrows``, ``ncols``, or ``buttons`` is set, otherwise a
     1915          dropdown menu)
     1916
     1917
     1918        * ``u = input_grid(nrows, ncols, default=None, label=None,
     1919          to_value=lambda x:x, width=4)`` -- an editable grid of
     1920          objects (a matrix or array)
     1921
     1922
     1923        * ``u = text_control(value='')`` -- a block of text
     1924
    17101925
    17111926    You can create a color selector by setting the default value for a
    1712     variable to Color(...).
     1927    variable to ``Color(...)``.
    17131928
    17141929    There are also some convenient defaults that allow you to make
    17151930    controls automatically without having to explicitly specify them.
    1716     E.g., you can make $x$ a continuous slider of values between $u$
    1717     and $v$ by just writing \code{x=(u,v)} in the argument list of
     1931    E.g., you can make ``x`` a continuous slider of values between ``u``
     1932    and ``v`` by just writing ``x=(u,v)`` in the argument list of
    17181933    your function.  These are all just convenient shortcuts for
    17191934    creating the controls listed above.
    17201935   
    1721     \begin{itemize}
    1722         \item u                 -- blank input_box field
    1723         \item u = element       -- input_box with default=element, if element not below.
    1724         \item u = (umin,umax)   -- continuous slider (really 100 steps)
    1725         \item u = (umin,umax,du)-- slider with step size du
    1726         \item u = list          -- buttons if len(list) at most 5; otherwise, drop down
    1727         \item u = generator     -- a slider (up to 10000 steps)
    1728         \item u = bool          -- a checkbox
    1729         \item u = Color('blue') -- a 2d RGB color selector; returns Color object
    1730         \item u = (default, v)  -- v as above, with given default value
    1731         \item u = (label, v)    -- v as above, with given label (a string)
    1732         \item u = matrix        -- an input_grid with to_value set to matrix.parent()
    1733                                    and default values given by the matrix
    1734     \end{itemize}
     1936        * ``u`` -- blank input_box field
     1937
     1938        * ``u = element`` -- input_box with ``default=element``, if
     1939          element not below.
     1940
     1941        * ``u = (umin,umax)`` -- continuous slider (really `100` steps)
     1942
     1943        * ``u = (umin,umax,du)`` -- slider with step size ``du``
     1944
     1945        * ``u = list`` -- buttons if ``len(list)`` at most `5`;
     1946          otherwise, drop down
     1947
     1948        * ``u = generator`` -- a slider (up to `10000` steps)
     1949
     1950        * ``u = bool`` -- a checkbox
     1951
     1952        * ``u = Color('blue')`` -- a 2D RGB color selector; returns
     1953          ``Color`` object
     1954
     1955        * ``u = (default, v)`` -- ``v`` as above, with given
     1956          ``default`` value
     1957
     1958        * ``u = (label, v)`` -- ``v`` as above, with given ``label``
     1959          (a string)
     1960
     1961        * ``u = matrix`` -- an ``input_grid`` with ``to_value`` set to
     1962          ``matrix.parent()`` and default values given by the matrix
    17351963
    17361964    WARNING: Suppose you would like to make a interactive with a
    1737     default rgb color of (1,0,0), so the function would have signature
    1738     \code{f(color=(1,0,0))}.  Unfortunately, the above shortcuts reinterpret
    1739     the (1,0,0) as a discrete slider with step size 0 between 1 and 0.
    1740     Instead you should do the following:
     1965    default RGB color of ``(1,0,0)``, so the function would have
     1966    signature ``f(color=(1,0,0))``.  Unfortunately, the above
     1967    shortcuts reinterpret the ``(1,0,0)`` as a discrete slider with
     1968    step size ``0`` between ``1`` and ``0``.  Instead you should do the
     1969    following::
     1970
    17411971        sage: @interact
    17421972        ... def _(v = input_box((1,0,0))):
    17431973        ...       show(plot(sin,color=v))
    17441974        <html>...
    17451975
    17461976    MORE EXAMPLES:
    1747     We give an input box that allows one to enter completely arbitrary strings.
     1977
     1978    We give an input box that allows one to enter completely arbitrary
     1979    strings::
     1980
    17481981        sage: @interact
    17491982        ... def _(a=input_box('sage', label="Enter your name", type=str)):
    17501983        ...        print "Hello there %s"%a.capitalize()
    17511984        <html>...
    17521985
    1753     The scope of variables that you control via interact are local to
    1754     the scope of the function being interacted with. However, by using
    1755     the global Python keyword, you can still modify global variables
    1756     as follows:
     1986    The scope of variables that you control via ``interact`` are local
     1987    to the scope of the function being interacted with. However, by
     1988    using the ``global`` Python keyword, you can still modify global
     1989    variables as follows::
     1990
    17571991        sage: xyz = 10
    17581992        sage: @interact
    17591993        ... def _(a=('xyz',5)):
     
    17611995        ...       xyz = a
    17621996        <html>...
    17631997
    1764     If you enter the above you obtain an interact canvas.  Entering
    1765     values in the box, changes the global variable xyz.
     1998    If you enter the above you obtain an ``interact`` canvas.  Entering
     1999    values in the box changes the global variable ``xyz``::
    17662000
    17672001        sage: @interact
    17682002        ... def _(title=["A Plot Demo", "Something silly", "something tricky"], a=input_box(sin(x*sin(x*sin(x))), 'function'),
     
    17722006        ...     show(plot(a, -zoom*pi,zoom*pi, color=clr, thickness=thickness, plot_points=plot_points))
    17732007        <html>...
    17742008
    1775     We give defaults and name the variables:
     2009    We give defaults and name the variables::
     2010
    17762011        sage: @interact
    17772012        ... def _(a=('first', (1,4)), b=(0,10)):
    17782013        ...       show(plot(sin(a*x+sin(b*x)), (x,0,6)), figsize=3)
    17792014        <html>...
    17802015
    1781     Another example involving labels and defaults, and the
    1782     slider command.
     2016    Another example involving labels, defaults, and the slider
     2017    command::
     2018
    17832019        sage: @interact
    17842020        ... def _(a = slider(1, 4, default=2, label='Multiplier'),
    17852021        ...       b = slider(0, 10, default=0, label='Phase Variable')):
    17862022        ...     show(plot(sin(a*x+b), (x,0,6)), figsize=4)
    17872023        <html>...
    17882024
    1789     An example where the range slider control is useful.
     2025    An example where the range slider control is useful::
     2026
    17902027        sage: @interact
    17912028        ... def _(b = range_slider(-20, 20, 1, default=(-19,3), label='Range')):
    17922029        ...     plot(sin(x)/x, b[0], b[1]).show(xmin=b[0],xmax=b[1])
    17932030        <html>...
    17942031
    1795     An example using checkboxes, obtained by making the default values bools.
     2032    An example using checkboxes, obtained by making the default values
     2033    bools::
     2034
    17962035        sage: @interact
    17972036        ... def _(axes=('Show axes', True), square=False):
    17982037        ...       show(plot(sin, -5,5), axes=axes, aspect_ratio = (1 if square else None))
    17992038        <html>...
    18002039
    1801     An example generating a random walk that uses a checkbox control to determine
    1802     whether points are placed at each step:
     2040    An example generating a random walk that uses a checkbox control
     2041    to determine whether points are placed at each step::
     2042
    18032043        sage: @interact
    18042044        ... def foo(pts = checkbox(True, "points"), n = (50,(10..100))):
    18052045        ...       s = 0; v = [(0,0)]
     
    18112051        ...       show(L)
    18122052        <html>...
    18132053
    1814     You can rotate and zoom into 3D graphics while
    1815     interacting with a variable.
     2054    You can rotate and zoom into 3D graphics while interacting with a
     2055    variable::
     2056
    18162057        sage: @interact
    18172058        ... def _(a=(0,1)):
    18182059        ...     x,y = var('x,y')
    18192060        ...     show(plot3d(sin(x*cos(y*a)), (x,0,5), (y,0,5)), figsize=4)
    18202061        <html>...
    18212062
    1822     A random polygon:
     2063    A random polygon::
     2064
    18232065        sage: pts = [(random(), random()) for _ in xrange(20)]
    18242066        sage: @interact
    18252067        ... def _(n = (4..len(pts)), c=Color('purple') ):
     
    18272069        ...     show(G, figsize=5, xmin=0, ymin=0)
    18282070        <html>...
    18292071
    1830     Two "sinks" displayed simultaneously via a contour plot and a 3d
    1831     interactive plot:
     2072    Two "sinks" displayed simultaneously via a contour plot and a 3D
     2073    interactive plot::
     2074
    18322075        sage: @interact
    18332076        ... def _(q1=(-1,(-3,3)), q2=(-2,(-3,3))):
    18342077        ...     x,y = var('x,y')
     
    18382081        ...     show(plot3d(f, (x,-2,2), (y,-2,2)), figsize=4)       
    18392082        <html>...
    18402083
    1841     This is similar to above, but you can select the color map from a dropdown menu:
     2084    This is similar to above, but you can select the color map from a
     2085    dropdown menu::
     2086
    18422087        sage: @interact
    18432088        ... def _(q1=(-1,(-3,3)), q2=(-2,(-3,3)),
    18442089        ...    cmap=['autumn', 'bone', 'cool', 'copper', 'gray', 'hot', 'hsv',
     
    18492094        ...     show(C, figsize=3, aspect_ratio=1)
    18502095        <html>...
    18512096
    1852     A quadratic roots etch-a-sketch:
     2097    A quadratic roots etch-a-sketch::
     2098
    18532099        sage: v = []
    18542100        sage: html('<h2>Quadratic Root Etch-a-sketch</h2>')
    18552101        <html><font color='black'><h2>Quadratic Root Etch-a-sketch</h2></font></html>
     
    18632109        ...       show(line(v, rgbcolor='purple') + point(P, pointsize=200))   
    18642110        <html>...
    18652111
    1866     In the following example, we only generate data for a given n
    1867     once, so that as one varies p the data doesn't not randomly
    1868     change.  We do this by simply caching the results for each n
    1869     in a dictionary.
     2112    In the following example, we only generate data for a given ``n``
     2113    once, so that as one varies ``p`` the data does not randomly change.
     2114    We do this by simply caching the results for each ``n`` in a
     2115    dictionary.::
     2116
    18702117        sage: data = {}
    18712118        sage: @interact
    18722119        ... def _(n=(500,(100,5000,1)), p=(1,(0.1,10))):
     
    18762123        ...     show(points([(x^p,y^p) for x,y in data[n]], rgbcolor='black'), xmin=0, ymin=0, axes=False)
    18772124        <html>...
    18782125
    1879     A conchoid:
     2126    A conchoid::
     2127
    18802128        sage: @interact
    18812129        ... def _(k=(1.2,(1.1,2)), k_2=(1.2,(1.1,2)), a=(1.5,(1.1,2))):
    18822130        ...     u, v = var('u,v')
     
    18842132        ...     show(parametric_plot3d(f, (u,0,6*pi), (v,0,2*pi), plot_points=[40,40], texture=(0,0.5,0)))
    18852133        <html>...
    18862134
    1887     An input grid:
     2135    An input grid::
     2136
    18882137        sage: @interact
    18892138        ... def _(A=matrix(QQ,3,3,range(9)), v=matrix(QQ,3,1,range(3))):
    18902139        ...     try:
     
    19372186class control:
    19382187    def __init__(self, label=None):
    19392188        """
    1940         An interactive control object used with the interact command.
     2189        An interactive control object used with the ``interact`` command.
    19412190        This is the abstract base class.
    19422191
    19432192        INPUTS:
    1944             label -- a string
     2193
     2194            ``label`` -- a string
    19452195           
    1946         EXAMPLES:
     2196        EXAMPLES::
     2197
    19472198            sage: sage.server.notebook.interact.control('a control')
    19482199            Interative control 'a control' (abstract base class)
    19492200        """
     
    19512202
    19522203    def __repr__(self):
    19532204        """
    1954         Return string representation of this control.
    1955         (It just mentions the label and that this is an abstract base class.)
     2205        Return string representation of this control.  (It just
     2206        mentions the label and that this is an abstract base class.)
    19562207
    1957         EXAMPLES:
     2208        EXAMPLES::
     2209
    19582210            sage: sage.server.notebook.interact.control('a control').__repr__()
    19592211            "Interative control 'a control' (abstract base class)"
    19602212        """
     
    19652217        Return the label of this control.
    19662218
    19672219        OUTPUT:
     2220
    19682221            a string
    19692222           
    1970         EXAMPLES:
     2223        EXAMPLES::
     2224
    19712225            sage: sage.server.notebook.interact.control('a control').label()
    19722226            'a control'
    19732227            sage: selector([1,2,7], 'alpha').label()
     
    19802234        Set the label of this control.
    19812235
    19822236        INPUT:
    1983             label -- a string
     2237
     2238            ``label`` -- a string
    19842239           
    1985         EXAMPLES:
     2240        EXAMPLES::
     2241
    19862242            sage: C = sage.server.notebook.interact.control('a control')
    19872243            sage: C.set_label('sage'); C
    19882244            Interative control 'sage' (abstract base class)
     
    19932249    def __init__(self, default=None, label=None, type=None, width = 80):
    19942250        r"""
    19952251        An input box interactive control.  Use this in conjunction
    1996         with the interact command.
     2252        with the ``interact`` command.
    19972253       
    1998         \code{input_box(default=None, label=None, type=None)}
     2254        ``input_box(default=None, label=None, type=None)``
    19992255       
    20002256        INPUT:
    2001             default -- object; the default put in this input box
    2002             label -- the label rendered to the left of the box.
    2003             type -- coerce inputs to this; this doesn't have to be
    2004                     an actual type, since anything callable will do.
    2005             width -- width of text box in characters
     2257
     2258            ``default`` -- object; the default put in this input box
     2259
     2260            ``label`` -- the label rendered to the left of the box.
     2261
     2262            ``type`` -- coerce inputs to this; this doesn't have to be
     2263            an actual type, since anything callable will do.
     2264
     2265            ``width`` -- width of text box in characters
    20062266           
    2007         EXAMPLES:
     2267        EXAMPLES::
     2268
    20082269            sage: input_box("2+2", 'expression')
    20092270            Interact input box labeled 'expression' with default value '2+2'
    20102271            sage: input_box('sage', label="Enter your name", type=str)
     
    20192280        """
    20202281        Return print representation of this input box.
    20212282
    2022         EXAMPLES:
     2283        EXAMPLES::
     2284
    20232285            sage: input_box("2+2", 'expression').__repr__()
    20242286            "Interact input box labeled 'expression' with default value '2+2'"
    20252287        """
     
    20292291        """
    20302292        Return the default value of this input box.
    20312293
    2032         EXAMPLES:
     2294        EXAMPLES::
     2295
    20332296            sage: input_box('2+2', 'Expression').default()
    20342297            '2+2'
    20352298            sage: input_box(x^2 + 1, 'Expression').default()
     
    20422305    def type(self):
    20432306        """
    20442307        Return the type that elements of this input box are coerced to
    2045         or None if they are not coerced (they have whatever type they
    2046         evaluate to).
     2308        or ``None`` if they are not coerced (they have whatever type
     2309        they evaluate to).
    20472310
    2048         EXAMPLES:
     2311        EXAMPLES::
     2312
    20492313            sage: input_box("2+2", 'expression', type=int).type()
    20502314            <type 'int'>
    20512315            sage: input_box("2+2", 'expression').type() is None
     
    20552319
    20562320    def render(self, var):
    20572321        r"""
    2058         Return rendering of this input box as an InputBox to be used
    2059         for an interact canvas.  Basically this specializes this
    2060         input to be used for a specific function and variable.
     2322        Return rendering of this input box as an ``InputBox`` to be
     2323        used for an ``interact`` canvas.  Basically this specializes
     2324        this input to be used for a specific function and variable.
    20612325       
    20622326        INPUT:
    2063             var -- a string (variable; one of the variable names input to f)
     2327
     2328            ``var`` -- a string (variable; one of the variable names
     2329            input to ``f``)
    20642330
    20652331        OUTPUT:
    2066             InputBox -- an InputBox object.
    20672332
    2068         EXAMPLES:
     2333            ``InputBox`` object.
     2334
     2335        EXAMPLES::
     2336
    20692337            sage: input_box("2+2", 'Exp').render('x')
    20702338            An InputBox interactive control with x='2+2' and label 'Exp'       
    20712339        """
     
    20792347    def __init__(self, nrows, ncols, default=None, label=None, to_value=lambda x: x, width=4):
    20802348        r"""
    20812349        An input grid interactive control.  Use this in conjunction
    2082         with the interact command.
     2350        with the ``interact`` command.
    20832351
    20842352        INPUT:
    2085             nrows -- integer
    2086             ncols -- integer
    2087             default -- object; the default put in this input box
    2088             label -- the label rendered to the left of the box.
    2089             to_value -- the grid output (list of rows) is sent through
    2090                         this function.  This may reformat the data or
    2091                         coerce the type.
    2092             width -- size of each input box in characters
     2353
     2354            ``nrows`` -- integer
     2355
     2356            ``ncols`` -- integer
     2357
     2358            ``default`` -- object; the default put in this input box
     2359
     2360            ``label`` -- the label rendered to the left of the box.
     2361
     2362            ``to_value`` -- the grid output (list of rows) is sent
     2363            through this function.  This may reformat the data or
     2364            coerce the type.
     2365
     2366            ``width`` -- size of each input box in characters
    20932367           
    20942368        NOTEBOOK EXAMPLE:
     2369
    20952370            @interact
    20962371            def _(m = input_grid(2,2, default = [[1,7],[3,4]],
    20972372                                 label='M=', to_value=matrix),
     
    21032378                except:
    21042379                    html('There is no solution to $$%s x=%s$$'%(latex(m), latex(v)))
    21052380
     2381        EXAMPLES::
    21062382
    2107         EXAMPLES:
    21082383            sage: input_grid(2,2, default = 0, label='M')
    21092384            Interact 2 x 2 input grid control labeled M with default value 0
    21102385            sage: input_grid(2,2, default = [[1,2],[3,4]], label='M')
     
    21262401        """
    21272402        Return print representation of this input box.
    21282403
    2129         EXAMPLES:
     2404        EXAMPLES::
     2405
    21302406            sage: input_grid(2,2, label='M').__repr__()
    21312407            'Interact 2 x 2 input grid control labeled M with default value None'
    21322408
     
    21402416        """
    21412417        Return the default value of this input grid.
    21422418
    2143         EXAMPLES:
     2419        EXAMPLES::
     2420
    21442421            sage: input_grid(2,2, default=1).default()
    21452422            1
    21462423        """
     
    21492426
    21502427    def render(self, var):
    21512428        r"""
    2152         Return rendering of this input grid as an InputGrid to be used
    2153         for an interact canvas.  Basically this specializes this
    2154         input to be used for a specific function and variable.
     2429        Return rendering of this input grid as an ``InputGrid`` to be
     2430        used for an ``interact`` canvas.  Basically this specializes
     2431        this input to be used for a specific function and variable.
    21552432       
    21562433        INPUT:
    2157             var -- a string (variable; one of the variable names input to f)
     2434
     2435            ``var`` -- a string (variable; one of the variable names
     2436            input to ``f``)
    21582437
    21592438        OUTPUT:
    2160             InputGrid -- an InputGrid object.
    21612439
    2162         EXAMPLES:
     2440            ``InputGrid`` object.
     2441
     2442        EXAMPLES::
     2443
    21632444            sage: input_grid(2,2).render('x')
    21642445            A 2 x 2 InputGrid interactive control with x=[[None, None], [None, None]] and label 'x'
    21652446           
     
    21712452class checkbox(input_box):
    21722453    def __init__(self, default=True, label=None):
    21732454        """
    2174         A checkbox interactive control.  Use this in conjecture
    2175         with the interact command.
     2455        A checkbox interactive control.  Use this in conjunction with
     2456        the ``interact`` command.
    21762457
    21772458        INPUT:
    2178             default -- bool (default: True); whether box should be checked or not
    2179             label -- str or None (default: None) text label rendered to the left of the box
    21802459
    2181         EXAMPLES:
     2460            ``default`` -- bool (default: ``True``); whether box
     2461            should be checked or not
     2462
     2463            ``label`` -- str or ``None`` (default: ``None``) text
     2464            label rendered to the left of the box
     2465
     2466        EXAMPLES::
     2467
    21822468            sage: checkbox(False, "Points")
    21832469            Interact checkbox labeled 'Points' with default value False
    21842470            sage: checkbox(True, "Points")
     
    21942480        """
    21952481        Print representation of this checkbox.
    21962482       
    2197         EXAMPLES:
     2483        EXAMPLES::
     2484
    21982485            sage: checkbox(True, "Points").__repr__()
    21992486            "Interact checkbox labeled 'Points' with default value True"
    22002487        """
     
    22482535        Returns list of values that this slider takes on, in order.
    22492536
    22502537        OUTPUT:
     2538
    22512539            list -- list of values
    22522540
    22532541        WARNING: This is a reference to a mutable list.
    22542542
    2255         EXAMPLES:
     2543        EXAMPLES::
     2544
    22562545            sage: sage.server.notebook.interact.slider(1,10,1/2).values()
    22572546            [1, 3/2, 2, 5/2, 3, 7/2, 4, 9/2, 5, 11/2, 6, 13/2, 7, 15/2, 8, 17/2, 9, 19/2, 10]
    22582547        """
     
    22632552        Returns whether to display the value on the slider.
    22642553       
    22652554        OUTPUT:
     2555
    22662556            boolean
    22672557           
    2268         EXAMPLES:
     2558        EXAMPLES::
     2559
    22692560            sage.server.notebook.interact.slider_generic(1,10,1/2).display_value()
    22702561            True
    22712562        """
     
    22762567    def __init__(self, vmin, vmax=None, step_size=None, default=None, label=None, display_value=True):
    22772568        r"""
    22782569        An interactive slider control, which can be used in conjunction
    2279         with the interact command.
     2570        with the ``interact`` command.
    22802571
    2281         \code{slider(vmin, vmax=None, step_size=1, default=None, label=None)}
     2572        ``slider(vmin, vmax=None, step_size=1, default=None, label=None)``
    22822573       
    22832574        INPUT:
    2284             vmin -- object or number
    2285             vmax -- object or None; if None then vmin must be a list, and the slider
    2286                     then varies over elements of the list.
    2287             step_size -- integer (default: 1)
    2288             default -- object or None; default value is ``closest'' in vmin or range
    2289                        to this default.
    2290             label -- string
    2291             display_value -- boolean, whether to display the current value to the right
    2292                              of the slider
    22932575
    2294         EXAMPLES:
    2295         We specify both vmin and vmax.  We make the default 3, but
    2296         since 3 isn't one of 3/17-th spaced values between 2 and 5,
    2297         52/17 is instead chosen as the default (it is closest).
     2576            ``vmin`` -- object or number
     2577
     2578            ``vmax`` -- object or ``None``; if ``None`` then ``vmin``
     2579            must be a list, and the slider then varies over elements
     2580            of the list.
     2581
     2582            ``step_size`` -- integer (default: ``1``)
     2583
     2584            ``default`` -- object or ``None``; default value is
     2585            "closest" in ``vmin`` or range to this default.
     2586
     2587            ``label`` -- string
     2588
     2589            ``display_value`` -- boolean, whether to display the
     2590            current value to the right of the slider
     2591
     2592        EXAMPLES::
     2593
     2594        We specify both ``vmin`` and ``vmax``.  We make the default
     2595        ``3``, but since ``3`` isn't one of ``3/17``-th spaced values
     2596        between ``2`` and ``5``, ``52/17`` is instead chosen as the
     2597        default (it is closest)::
     2598
    22982599            sage: slider(2, 5, 3/17, 3, 'alpha')
    22992600            Slider: alpha [2--|52/17|---5]
    23002601
    2301         Here we give a list:
     2602        Here we give a list::
     2603
    23022604            sage: slider([1..10], None, None, 3, 'alpha')
    23032605            Slider: alpha [1--|3|---10]
    23042606
    2305         The elements of the list can be anything:
     2607        The elements of the list can be anything::
     2608
    23062609            sage: slider([1, 'x', 'abc', 2/3], None, None, 'x', 'alpha')
    23072610            Slider: alpha [1--|x|---2/3]           
    23082611        """
     
    23292632        """
    23302633        Return string representation of this slider.
    23312634       
    2332         EXAMPLES:
     2635        EXAMPLES::
     2636
    23332637            sage: slider(2, 5, 1/5, 3, 'alpha').__repr__()
    23342638            'Slider: alpha [2--|3|---5]'
    23352639        """
     
    23432647        Return default index into the list of values.
    23442648
    23452649        OUTPUT:
     2650
    23462651            int
    23472652
    2348         EXAMPLES:
     2653        EXAMPLES::
     2654
    23492655            sage: slider(2, 5, 1/2, 3, 'alpha').default_index()
    23502656            2
    23512657        """
     
    23532659
    23542660    def render(self, var):
    23552661        """
    2356         Render the interact control for the given function and
     2662        Render the ``interact`` control for the given function and
    23572663        variable.
    23582664
    23592665        INPUT:
    2360             var -- string; variable name
    23612666
    2362         EXAMPLES:
     2667            ``var`` -- string; variable name
     2668
     2669        EXAMPLES::
     2670
    23632671            sage: S = slider(0, 10, 1, default=3, label='theta'); S
    23642672            Slider: theta [0--|3|---10]
    23652673            sage: S.render('x')
     
    23752683    def __init__(self, vmin, vmax=None, step_size=None, default=None, label=None, display_value=True):
    23762684        r"""
    23772685        An interactive range slider control, which can be used in conjunction
    2378         with the interact command.
     2686        with the ``interact`` command.
    23792687
    2380         \code{range_slider(vmin, vmax=None, step_size=1, default=None, label=None)}
     2688        ``range_slider(vmin, vmax=None, step_size=1, default=None, label=None)``
    23812689       
    23822690        INPUT:
    2383             vmin -- object or number
    2384             vmax -- object or None; if None then vmin must be a list, and the slider
    2385                     then varies over elements of the list.
    2386             step_size -- integer (default: 1)
    2387             default -- (object, object) or None; default range is ``closest'' in vmin or range
    2388                        to this default.
    2389             label -- string
    2390             display_value -- boolean, whether to display the current value below
    2391                              the slider
    23922691
    2393         EXAMPLES:
    2394         We specify both vmin and vmax.  We make the default (3,4) but
    2395         since neither is one of 3/17-th spaced values between 2 and 5,
    2396         the closest values: 52/17 and 67/17, are instead chosen as the
    2397         default.
     2692            ``vmin`` -- object or number
     2693
     2694            ``vmax`` -- object or ``None``; if ``None`` then ``vmin``
     2695            must be a list, and the slider then varies over elements
     2696            of the list.
     2697
     2698            ``step_size`` -- integer (default: ``1``)
     2699
     2700            ``default`` -- (object, object) or ``None``; default range
     2701            is "closest" in ``vmin`` or range to this default.
     2702
     2703            ``label`` -- string
     2704
     2705            ``display_value`` -- boolean, whether to display the
     2706            current value below the slider
     2707
     2708        EXAMPLES::
     2709
     2710        We specify both ``vmin`` and ``vmax``.  We make the default
     2711        ``(3,4)`` but since neither is one of ``3/17``-th spaced
     2712        values between ``2`` and ``5``, the closest values: ``52/17``
     2713        and ``67/17``, are instead chosen as the default::
     2714
    23982715            sage: range_slider(2, 5, 3/17, (3,4), 'alpha')
    23992716            Range Slider: alpha [2--|52/17==67/17|---5]
    24002717           
    2401         Here we give a list:
     2718        Here we give a list::
     2719
    24022720            sage: range_slider([1..10], None, None, (3,7), 'alpha')
    24032721            Range Slider: alpha [1--|3==7|---10]
    24042722        """
     
    24302748        """
    24312749        Return string representation of this slider.
    24322750       
    2433         EXAMPLES:
     2751        EXAMPLES::
     2752
    24342753            sage: range_slider(2, 5, 1/5, (3,4), 'alpha').__repr__()
    24352754            'Range Slider: alpha [2--|3==4|---5]'
    24362755        """
     
    24432762        Return default index into the list of values.
    24442763
    24452764        OUTPUT:
     2765
    24462766            (int, int)
    24472767
    2448         EXAMPLES:
     2768        EXAMPLES::
     2769
    24492770            sage: range_slider(2, 5, 1/2, (3,4), 'alpha').default_index()
    24502771            (2, 4)
    24512772        """
     
    24532774
    24542775    def render(self, var):
    24552776        """
    2456         Render the interact control for the given function and
     2777        Render the ``interact`` control for the given function and
    24572778        variable.
    24582779
    24592780        INPUT:
    2460             var -- string; variable name
    24612781
    2462         EXAMPLES:
     2782            ``var`` -- string; variable name
     2783
     2784        EXAMPLES::
     2785
    24632786            sage: S = range_slider(0, 10, 1, default=(3,7), label='theta'); S
    24642787            Range Slider: theta [0--|3==7|---10]
    24652788            sage: S.render('x')
     
    24772800        r"""
    24782801        A drop down menu or a button bar that when pressed sets a
    24792802        variable to a given value.  Use this in conjunction with the
    2480         interact command.
     2803        ``interact`` command.
    24812804
    2482         \code{selector(values, label=None, nrows=None, ncols=None, buttons=False)}
     2805        ``selector(values, label=None, nrows=None, ncols=None, buttons=False)``
    24832806
    24842807        We use the same command to create either a drop down menu or
    24852808        selector bar of buttons, since conceptually the two controls
    24862809        do exactly the same thing -- they only look different.  If
    2487         either nrows or ncols is given, then you get a buttons instead
    2488         of a drop down menu.
     2810        either ``nrows`` or ``ncols`` is given, then you get a buttons
     2811        instead of a drop down menu.
    24892812       
    24902813        INPUT:
    2491             values -- [val0, val1, val2, ...] or
    2492                       [(val0, lbl0), (val1,lbl1), ...] where all labels must be
    2493                                                        given or given as None.
    2494             label -- (default: None); if given, this label is placed to
    2495                                       the left of the entire button group
    2496             default -- object (default: 0) default value in values list
    2497             nrows -- (default: None); if given determines the number
    2498                      of rows of buttons; if given buttons option below is set to True
    2499             ncols -- (default: None); if given determines the number
    2500                      of columns of buttons; if given buttons option below is set to True
    2501             width -- (default: None); if given, all buttons are the same
    2502                      width, equal to this in html ex units's.
    2503             buttons -- (default: False); if True, use buttons         
    25042814
    2505         EXAMPLES:
     2815            ``values`` -- [val0, val1, val2, ...] or [(val0, lbl0),
     2816                      (val1,lbl1), ...] where all labels must be given
     2817                      or given as None.
     2818
     2819            ``label`` -- (default: ``None``); if given, this label is
     2820            placed to the left of the entire button group
     2821
     2822            ``default`` -- object (default: ``0``) default value in
     2823            values list
     2824
     2825            ``nrows`` -- (default: ``None``); if given determines the
     2826            number of rows of buttons; if given buttons option below
     2827            is set to ``True``
     2828
     2829            ``ncols`` -- (default: ``None``); if given determines the
     2830            number of columns of buttons; if given buttons option
     2831            below is set to ``True``
     2832
     2833            ``width`` -- (default: ``None``); if given, all buttons
     2834            are the same width, equal to this in HTML ex units's.
     2835
     2836            ``buttons`` -- (default: ``False``); if ``True``, use buttons         
     2837
     2838        EXAMPLES::
     2839
    25062840            sage: selector([1..5])   
    25072841            Drop down menu with 5 options
    25082842            sage: selector([1,2,7], default=2)
     
    25162850            sage: selector([1,2,7], buttons=True)
    25172851            Button bar with 3 buttons
    25182852
    2519         We create an interactive that involves computing charpolys of matrices over various rings:
     2853        We create an ``interact`` that involves computing charpolys of
     2854        matrices over various rings::
     2855
    25202856            sage: @interact
    25212857            ... def _(R=selector([ZZ,QQ,GF(17),RDF,RR]), n=(1..10)):
    25222858            ...      M = random_matrix(R, n)
     
    25262862            ...      print f
    25272863            <html>...
    25282864
    2529         Here we create a drop-down
     2865        Here we create a drop-down::
     2866
    25302867            sage: @interact
    25312868            ... def _(a=selector([(2,'second'), (3,'third')])):
    25322869            ...       print a
     
    25532890        """
    25542891        Return print representation of this button.
    25552892
    2556         EXAMPLES:
     2893        EXAMPLES::
     2894
    25572895            sage: selector([1,2,7], default=2).__repr__()
    25582896            'Drop down menu with 3 options'
    25592897        """
     
    25682906        selector can take on.
    25692907
    25702908        OUTPUT:
     2909
    25712910            list
    25722911
    2573         EXAMPLES:
     2912        EXAMPLES::
     2913
    25742914            sage: selector([1..5]).values()   
    25752915            [1, 2, 3, 4, 5]
    25762916            sage: selector([(5,'fifth'), (8,'eight')]).values()
     
    25832923        Return the default choice for this control.
    25842924
    25852925        OUTPUT:
    2586            int -- an integer, with 0 corresponding to the first choice.
    25872926
    2588         EXAMPLES:
     2927           int -- an integer, with ``0`` corresponding to the first choice.
     2928
     2929        EXAMPLES::
     2930
    25892931            sage: selector([1,2,7], default=2).default()
    25902932            1       
    25912933        """
     
    25932935
    25942936    def render(self, var):
    25952937        r"""
    2596         Return rendering of this button as a Button instance to be
    2597         used for an interact canvas.
     2938        Return rendering of this button as a ``Button`` instance to be
     2939        used for an ``interact`` canvas.
    25982940       
    25992941        INPUT:
    2600             var -- a string (variable; one of the variable names input to f)
     2942
     2943            ``var`` -- a string (variable; one of the variable names
     2944            input to ``f``)
    26012945
    26022946        OUTPUT:
    2603             Button -- a Button instance
    26042947
    2605         EXAMPLES:
     2948            ``Button`` instance
     2949
     2950        EXAMPLES::
     2951
    26062952            sage: selector([1..5]).render('alpha')
    26072953            Selector with 5 options for variable 'alpha'
    26082954        """
     
    26142960class text_control(control):
    26152961    def __init__(self, value=''):
    26162962        """
    2617         Text that can be inserted among other interact controls.
     2963        Text that can be inserted among other ``interact`` controls.
    26182964
    26192965        INPUT:
    2620             value -- HTML for the control
    26212966
    2622         EXAMPLES:
     2967            ``value`` -- HTML for the control
     2968
     2969        EXAMPLES::
     2970
    26232971            sage: text_control('something')
    26242972            Text field: something
    26252973        """
     
    26302978        """
    26312979        Return print representation of this control.
    26322980
    2633         EXAMPLES:
     2981        EXAMPLES::
     2982
    26342983            sage: text_control('something')
    26352984            Text field: something
    26362985        """
     
    26412990        Return rendering of the text field
    26422991       
    26432992        INPUT:
    2644             var -- a string (variable; one of the variable names input to f)
     2993
     2994            ``var`` -- a string (variable; one of the variable names
     2995            input to ``f``)
    26452996
    26462997        OUTPUT:
    2647             TextControl -- a TextControl instance
     2998
     2999            ``TextControl`` instance
    26483000        """
    26493001        return TextControl(var, self.__default)
    26503002
     
    26553007    value of the variable.
    26563008
    26573009    INPUT:
    2658         default -- the default value for v given by the function; see
    2659                    the documentation to interact? for details.
     3010
     3011        ``default`` -- the default value for `v` given by the
     3012        function; see the documentation to ``interact`` for details.
    26603013
    26613014    OUTPUT:
    2662         a interact control
    26633015
    2664     EXAMPLES:
     3016        ``interact`` control
     3017
     3018    EXAMPLES::
     3019
    26653020        sage: sage.server.notebook.interact.automatic_control('')
    26663021        Interact input box labeled None with default value ''
    26673022        sage: sage.server.notebook.interact.automatic_control(15)
     
    27643119
    27653120
    27663121def update(cell_id, var, adapt, value, globs):
    2767     """
     3122    r"""
    27683123    Called when updating the positions of an interactive control.
    27693124    Note that this just causes the values of the variables to be
    27703125    updated; it does not reevaluate the function with the new values.
    27713126   
    27723127    INPUT:
    2773         cell_id -- the id of a interact cell
    2774         var -- a variable associated to that cell
    2775         adapt -- the number of the adapt function
    2776         value -- new value of the control
    2777         globs -- global variables.
     3128        ``cell_id`` -- the id of an ``interact`` cell
     3129
     3130        ``var`` -- a variable associated to that cell
     3131
     3132        ``adapt`` -- the number of the adapt function
     3133
     3134        ``value`` -- new value of the control
     3135
     3136        ``globs`` -- global variables.
    27783137
    27793138    EXAMPLES:
     3139
    27803140    The following outputs __SAGE_INTERACT_RESTART__ to indicate that
    2781     not all the state of the interrupt canvas has been setup yet (this
    2782     setup happens when javascript calls certain functions).
     3141    not all the state of the ``interact`` canvas has been set up yet
     3142    (this setup happens when JavaScript calls certain functions)::
     3143
    27833144        sage: sage.server.notebook.interact.update(0, 'a', 0, '5', globals())
    27843145        __SAGE_INTERACT_RESTART__         
    27853146    """
     
    27953156
    27963157def recompute(cell_id):
    27973158    """
    2798     Evaluates the interact function associated to the cell
    2799     cell_id. This typically gets called after a call to
    2800     sage.server.notebook.interact.update.
     3159    Evaluates the ``interact`` function associated to the cell
     3160    ``cell_id``. This typically gets called after a call to
     3161    ``sage.server.notebook.interact.update``.
    28013162   
    28023163    EXAMPLES:
     3164
    28033165    The following outputs __SAGE_INTERACT_RESTART__ to indicate that
    2804     not all the state of the interrupt canvas has been setup yet (this
    2805     setup happens when javascript calls certain functions).
     3166    not all the state of the ``interact`` canvas has been set up yet
     3167    (this setup happens when JavaScript calls certain functions)::
     3168
    28063169        sage: sage.server.notebook.interact.recompute(10)
    28073170        __SAGE_INTERACT_RESTART__         
    28083171
  • sage/server/notebook/js.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/js.py
    a b  
    11r"""nodoctest
    2 Javascript (AJAX) Component of \sage Notebook
     2JavaScript (AJAX) Components of the Notebook
    33
    44AUTHORS:
    55
  • sage/server/notebook/notebook.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/notebook.py
    a b  
    284284
    285285    def create_user_with_same_password(self, user, other_user):
    286286        r"""
     287        Changes password of ``user`` to that of ``other_user``.
     288       
    287289        INPUT:
    288290       
    289291       
    290292        -  ``user`` - a string
    291293       
    292         -  ``other_user`` - a string
     294        -  ``other_user`` - a strin
    293295       
    294296       
    295         OUTPUT: Changes password of ``user`` to that of
    296         ``other_user``.
    297        
    298297        EXAMPLES::
    299298       
    300299            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     
    315314
    316315    def user_is_admin(self, user):
    317316        """
     317        Returns true if ``user`` is an admin.
     318
     319        INPUT:
     320
     321        - user - instance of User
     322       
    318323        EXAMPLES::
    319324       
    320325            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    321             sage: nb.add_user('Administrator', 'password', ", 'admin', True)
    322             sage: nb.add_user('RegularUser', 'password', ", 'user', True)
     326            sage: nb.add_user('Administrator', 'password', '', 'admin', True)
     327            sage: nb.add_user('RegularUser', 'password', '', 'user', True)
    323328            sage: nb.user_is_admin('Administrator')
    324329            True
    325330            sage: nb.user_is_admin('RegularUser')
     
    329334
    330335    def user_is_guest(self, username):
    331336        """
     337        Returns true if ``username`` is a guest.
     338
     339        INPUT:
     340
     341        - username - String of the username
     342       
    332343        EXAMPLES::
    333344       
    334345            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     
    384395            Creating default users.
    385396            sage: nb.valid_login_names()
    386397            ['admin']
    387             sage: nb.add_user('Mark', 'password', ", force=True)
    388             sage: nb.add_user('Sarah', 'password', ", force=True)
    389             sage: nb.add_user('David', 'password', ", force=True)
     398            sage: nb.add_user('Mark', 'password', '', force=True)
     399            sage: nb.add_user('Sarah', 'password', '', force=True)
     400            sage: nb.add_user('David', 'password', '', force=True)
    390401            sage: sorted(nb.valid_login_names())
    391402            ['David', 'Mark', 'Sarah', 'admin']
    392403        """
    393404        return [x for x in self.usernames() if not x in ['guest', '_sage_', 'pub']]
    394405
    395406    def default_user(self):
    396         """
     407        r"""
    397408        Return a default login name that the user will see when confronted
    398409        with the Sage notebook login page.
    399410       
    400         OUTPUT: string
    401        
    402         Currently this returns 'admin' if that is the *only* user.
    403         Otherwise it returns the string ".
     411        OUTPUT:
     412
     413        string -- the default username. Currently this returns 'admin'
     414        if that is the *only* user.  Otherwise it returns an empty string
     415        ('').
    404416       
    405417        EXAMPLES::
    406418       
     
    409421            Creating default users.
    410422            sage: nb.default_user()
    411423            'admin'
    412             sage: nb.add_user('AnotherUser', 'password', ", force=True)
     424            sage: nb.add_user('AnotherUser', 'password', '', force=True)
    413425            sage: nb.default_user()
    414426            ''
    415427        """
     
    478490        EXAMPLES::
    479491       
    480492            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    481             sage: nb.add_user('Mark', 'password', ", force=True)
     493            sage: nb.add_user('Mark', 'password', '', force=True)
    482494            sage: nb.user('Mark')
    483495            Mark
    484496            sage: nb.add_user('Sarah', 'password', ")
     
    512524        EXAMPLES::
    513525       
    514526            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    515             sage: nb.add_user('Mark', 'password', ", force=True)
     527            sage: nb.add_user('Mark', 'password', '', force=True)
    516528            sage: nb.user('Mark').password()
    517529            'aajfMKNH1hTm2'
    518530            sage: nb.change_password('Mark', 'different_password')
     
    528540        EXAMPLES::
    529541       
    530542            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    531             sage: nb.add_user('Mark', 'password', ", force=True)
     543            sage: nb.add_user('Mark', 'password', '', force=True)
    532544            sage: nb.user('Mark')
    533545            Mark
    534546            sage: nb.del_user('Mark')
     
    549561            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    550562            sage: nb.create_default_users('password')
    551563            Creating default users.
    552             sage: nb.add_user('Mark', 'password', ", force=True)
     564            sage: nb.add_user('Mark', 'password', '', force=True)
    553565            sage: list(sorted(nb.passwords().iteritems()))
    554566            [('Mark', 'aajfMKNH1hTm2'), ('_sage_', 'aaQSqAReePlq6'), ('admin', 'aajfMKNH1hTm2'), ('guest', 'aaQSqAReePlq6'), ('pub', 'aaQSqAReePlq6')]
    555567        """
     
    11701182        Outputs html containing the plain text version of a worksheet
    11711183
    11721184        INPUT:
     1185
     1186       
    11731187        - ``filename`` - filename of a worksheet
     1188       
    11741189        - ``prompts``  - boolean
    11751190
    11761191        OUTPUT:
    1177         - A string containing the html for the plain text version
     1192       
     1193        - string -- containing the html for the plain text version
    11781194        """
    11791195        worksheet = self.get_worksheet_with_filename(filename)
    11801196        text = escape(worksheet.plain_text(prompts = prompts))
     
    13091325        return s
    13101326
    13111327    def worksheet_html(self, filename, do_print=False):
    1312         """
     1328        r"""
    13131329        Returns the HTML for the worksheet.
    13141330
    13151331        INPUT:
     1332
     1333       
    13161334        - ``username`` - a string
     1335       
    13171336        - ``worksheet`` - an instance of Worksheet
    13181337
    13191338        OUTPUT:
    1320         - a string containing the HTML
     1339       
     1340        - string -- the HTML for the worksheet
    13211341
    13221342        EXAMPLES::
    13231343       
     
    13591379    # Revision history for a worksheet
    13601380    ##########################################################
    13611381    def html_worksheet_revision_list(self, username, worksheet):
    1362         """
     1382        r"""
    13631383        Returns the HTML for the revision list of a worksheet.
    13641384
    13651385        INPUT:
     1386
     1387       
    13661388        - ``username`` - a string
     1389       
    13671390        - ``worksheet`` - an instance of Worksheet
    13681391
    13691392        OUTPUT:
    1370         - a string containing the HTML
     1393
     1394       
     1395        - string -- the HTML for the revision list
    13711396
    13721397        EXAMPLES::
    13731398       
     
    13891414
    13901415
    13911416    def html_specific_revision(self, username, ws, rev):
    1392         """
     1417        r"""
    13931418        Returns the HTML for a revision of the worksheet.
    13941419
    13951420        INPUT:
     1421
     1422       
    13961423        - ``username`` - a string
     1424       
    13971425        - ``ws`` - an instance of Worksheet
     1426       
    13981427        - ``rev`` - a string containing the key of the revision
    13991428
    14001429        OUTPUT:
    1401         - a string containing the HTML
     1430       
     1431        - string -- the HTML for the revision
    14021432        """
    14031433        t = time.time() - float(rev[:-4])
    14041434        time_ago = worksheet.convert_seconds_to_meaningful_time_span(t)
     
    14341464       
    14351465
    14361466    def html_share(self, worksheet, username):
    1437         """
     1467        r"""
    14381468        Returns the HTML for the share page of a worksheet.
    14391469
    14401470        INPUT:
     1471
     1472       
    14411473        - ``username`` - a string
     1474       
    14421475        - ``worksheet`` - an instance of Worksheet
    14431476
    14441477        OUTPUT:
    1445         - a string containing the HTML
     1478
     1479       
     1480        - string -- the HTML for the share page
    14461481       
    14471482        EXAMPLES::
    14481483       
     
    14661501
    14671502
    14681503    def html_download_or_delete_datafile(self, ws, username, filename):
    1469         """
     1504        r"""
    14701505        Returns the HTML for the download or delete datafile page.
    14711506
    14721507        INPUT:
     1508
     1509       
    14731510        - ``username`` - a string
     1511       
    14741512        - ``ws`` - an instance of Worksheet
     1513       
    14751514        - ``filename`` - the name of the file
    14761515
    14771516        OUTPUT:
    1478         - a string containing the HTML
     1517
     1518       
     1519        - string -- the HTML for the page
    14791520
    14801521        EXAMPLES::
    14811522       
     
    16131654    # HTML -- generate most html related to the whole notebook page
    16141655    ###########################################################
    16151656    def html_debug_window(self):
    1616         """
     1657        r"""
    16171658        Returns the HTML for the debug window
    16181659
    16191660        OUTPUT:
    1620         - the HTML for the debug window
     1661       
     1662        - string -- the HTML for the debug window
    16211663   
    16221664        EXAMPLES::
    16231665
    1624         sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    1625         sage: print(nb.html_debug_window())
    1626         <div class='debug_window'>
    1627             <div class='debug_output'><pre id='debug_output'></pre></div>
    1628             <textarea rows=5 id='debug_input' class='debug_input'
    1629                       onKeyPress='return debug_keypress(event);'
    1630                       onFocus='debug_focus();' onBlur='debug_blur();'></textarea>
    1631         </div>
     1666            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1667            sage: nb.html_debug_window()
     1668            "\n<div class='debug_window'>...</div>"
    16321669        """
    16331670        return template("notebook/debug_window.html")
    16341671
    16351672   
    16361673    def html_plain_text_window(self, worksheet, username):
    1637         """
     1674        r"""
    16381675        Returns a window that displays a plain text version of the
    16391676        worksheet
    16401677       
    16411678        INPUT:
     1679
     1680       
    16421681        -  ``worksheet`` - a worksheet
     1682       
    16431683        -  ``username`` - name of the user
    16441684
    16451685        OUTPUT:
    1646         - a window that displays a plain text version of the
    1647         worksheet
     1686
     1687       
     1688        - string -- html for a window that displays a plain text
     1689        version of the worksheet
    16481690       
    16491691        EXAMPLES::
    16501692       
     
    16691711        Return a window for editing ``worksheet``.
    16701712       
    16711713        INPUT:
     1714
     1715       
    16721716        - ``username`` - a string containing the username
     1717       
    16731718        - ``worksheet`` - a Worksheet instance
    16741719
    16751720        OUTPUT:
     1721       
    16761722        - html for a window for editing ``worksheet``.
    16771723
    16781724        EXAMPLES::
     
    16951741                        sage_jsmath_macros = sage_jsmath_macros)
    16961742   
    16971743    def html_beforepublish_window(self, worksheet, username):
    1698         """
     1744        r"""
    16991745        Return the html code for a page dedicated to worksheet publishing
    17001746        prior to the publication of the given worksheet.
    17011747       
    17021748        INPUT:
     1749
     1750       
    17031751        - ``worksheet`` - instance of Worksheet
     1752       
    17041753        - ``username`` - string
    17051754
    17061755        EXAMPLES::
     
    17281777                        sage_jsmath_macros = sage_jsmath_macros)
    17291778       
    17301779    def html_afterpublish_window(self, worksheet, username, url, dtime):
    1731         """
     1780        r"""
    17321781        Return the html code for a page dedicated to worksheet publishing
    17331782        after the publication of the given worksheet.
    17341783       
    17351784        INPUT:
     1785
     1786       
    17361787        - ``worksheet`` - instance of Worksheet
     1788       
    17371789        - ``username`` - string
     1790       
    17381791        - ``url`` - a string representing the url of the published worksheet
     1792       
    17391793        - ``dtime`` - instance of time.struct_time representing the publishing time
    17401794        """
    17411795        from time import strftime
     
    17501804                        sage_jsmath_macros = sage_jsmath_macros)
    17511805
    17521806    def html_upload_data_window(self, ws, username):
    1753         """
     1807        r"""
    17541808        Returns the html for the "Upload Data" window
    17551809
    17561810        INPUT:
     1811
     1812       
    17571813        - ``worksheet`` - instance of Worksheet
     1814       
    17581815        - ``username`` - string
    17591816
    17601817        EXAMPLES::
     
    17731830   
    17741831
    17751832    def html(self, worksheet_filename=None, username='guest', show_debug=False, admin=False):
    1776         """
     1833        r"""
    17771834        Returns the html for index page of a worksheet.
    17781835
    17791836        INPUT:
     1837
     1838       
    17801839        - ``worksheet_filename`` - a string
     1840       
    17811841        - ``username`` - a string
     1842
    17821843        - ``show_debug`` - a boolean
     1844       
    17831845        - ``admin`` - a boolean
    17841846
    17851847        EXAMPLES::
     
    18201882
    18211883
    18221884    def html_worksheet_settings(self, ws, username):
    1823         """
     1885        r"""
    18241886        Returns the html for the setings page of the worksheet.
    18251887       
    18261888        INPUT:
     1889       
    18271890        - ``ws`` - instance of Worksheet
     1891       
    18281892        - ``username`` - string
    18291893
    18301894        EXAMPLES::
     
    18561920        return s
    18571921
    18581922    def html_doc(self, username):
    1859         """
     1923        r"""
    18601924        Returns the html for the documentation pages.
    18611925       
    18621926        INPUT:
     1927       
    18631928        - ``worksheet_filename`` - a string
     1929       
    18641930        - ``username`` - a string
     1931       
    18651932        - ``show_debug`` - a boolean
     1933       
    18661934        - ``admin`` - a boolean
    18671935
    18681936        EXAMPLES::
  • sage/server/notebook/sage_email.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/sage_email.py
    a b  
    66email server or anything else, since Sage already includes by default
    77a sophisticated email server (which is part of Twisted).
    88
    9 EXAMPLES:
     9EXAMPLES::
     10
    1011    sage: email('xxxsageuser@gmail.com', 'The calculation finished!')  # not tested
    1112    Child process ... is sending email to xxxsageuser@gmail.com
    1213
     
    3233    OUTPUT:
    3334        string
    3435     
    35     EXAMPLES:
     36    EXAMPLES::
     37
    3638        sage: sage.server.notebook.sage_email.default_email_address()     
    3739        '...@...'
    3840    """
     
    6466                        be a problem, but might be useful for certain
    6567                        users.
    6668                       
    67     EXAMPLES:
     69    EXAMPLES::
     70
    6871        sage: email('xxxsageuser@gmail.com', 'The calculation finished!')  # not tested
    6972        Child process ... is sending email to xxxsageuser@gmail.com
    7073
  • sage/server/notebook/sagetex.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/sagetex.py
    a b  
    88
    99    THIS IS ONLY A PROOF-of-CONCEPT.
    1010
    11     EXAMPLES:
     11    EXAMPLES::
     12
    1213        sage: sagetex('foo.tex')        # not tested
    1314        [pops up web browser with live version of foo.tex.]
    1415    """
  • sage/server/notebook/template.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/template.py
    a b  
    11# -*- coding: utf-8 -*-
    22"""
    3 HTML templating for the notebook
     3HTML Templating for the Notebook
    44
    55AUTHORS:
    66    -- Bobby Moretti (2007-07-18): initial version
     
    2626    and returns True if that value is in the container and False
    2727    otherwise.  This is registered and used as a test in the templates.
    2828
    29     EXAMPLES:
     29    EXAMPLES::
     30
    3031        sage: from sage.server.notebook.template import contained_in
    3132        sage: f = contained_in([1,2,3])
    3233        sage: f(None, None, 2)
     
    5455        filename -- the filename of the template relative to
    5556                    $SAGE_ROOT/devel/sage/sage/server/notebook/templates
    5657
    57     EXAMPLES:
     58    EXAMPLES::
     59
    5860        sage: from sage.server.notebook.template import template
    5961        sage: s = template('yes_no.html'); type(s)
    6062        <type 'str'>
  • sage/server/notebook/twist.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/twist.py
    a b  
    134134    Returns an HTMLResponse object whose 'Content-Type' header has been set
    135135    to 'text/html; charset=utf-8
    136136
    137     EXAMPLES:
     137    EXAMPLES::
     138
    138139        sage: from sage.server.notebook.twist import HTMLResponse
    139140        sage: response = HTMLResponse(stream='<html><head><title>Test</title></head><body>Test</body></html>')
    140141        sage: response.headers
  • sage/server/notebook/user.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/user.py
    a b  
    6363
    6464    def username(self):
    6565        """
    66         EXAMPLES:
     66        EXAMPLES::
     67
    6768            sage: from sage.server.notebook.user import User
    6869            sage: User('andrew', 'tEir&tiwk!', 'andrew@matrixstuff.com', 'user').username()
    6970            'andrew'
     
    7980
    8081    def conf(self):
    8182        """
    82         EXAMPLES:
     83        EXAMPLES::
     84
    8385            sage: from sage.server.notebook.user import User
    8486            sage: config = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin').conf(); config
    8587            Configuration: {}
     
    102104
    103105    def password(self):
    104106        """
    105         EXAMPLES:
     107        EXAMPLES::
     108
    106109            sage: from sage.server.notebook.user import User
    107110            sage: user = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin')
    108111            sage: user.password()
     
    112115
    113116    def set_password(self, password):
    114117        """
    115         EXAMPLES:
     118        EXAMPLES::
     119
    116120            sage: from sage.server.notebook.user import User
    117121            sage: user = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin')
    118122            sage: old = user.password()
     
    127131
    128132    def set_hashed_password(self, password):
    129133        """
    130         EXAMPLES:
     134        EXAMPLES::
     135
    131136            sage: from sage.server.notebook.user import User
    132137            sage: user = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin')
    133138            sage: user.set_hashed_password('Crrc!')
     
    138143
    139144    def get_email(self):
    140145        """
    141         EXAMPLES:
     146        EXAMPLES::
     147
    142148            sage: from sage.server.notebook.user import User
    143149            sage: user = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin')
    144150            sage: user.get_email()
     
    148154
    149155    def set_email(self, email):
    150156        """
    151         EXAMPLES:
     157        EXAMPLES::
     158
    152159            sage: from sage.server.notebook.user import User
    153160            sage: user = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin')
    154161            sage: user.get_email()
     
    161168       
    162169    def set_email_confirmation(self, value):
    163170        """
    164         EXAMPLES:
     171        EXAMPLES::
     172
    165173            sage: from sage.server.notebook.user import User
    166174            sage: user = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin')
    167175            sage: user.is_email_confirmed()
     
    178186       
    179187    def is_email_confirmed(self):
    180188        """
    181         EXAMPLES:
     189        EXAMPLES::
     190
    182191            sage: from sage.server.notebook.user import User
    183192            sage: user = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin')
    184193            sage: user.is_email_confirmed()
     
    192201
    193202    def password_is(self, password):
    194203        """
    195         EXAMPLES:
     204        EXAMPLES::
     205
    196206            sage: from sage.server.notebook.user import User
    197207            sage: user = User('bob', 'Aisfa!!', 'bob@sagemath.net', 'admin')
    198208            sage: user.password_is('ecc')
     
    206216
    207217    def account_type(self):
    208218        """
    209         EXAMPLES:
     219        EXAMPLES::
     220
    210221            sage: from sage.server.notebook.user import User
    211222            sage: User('A', account_type='admin').account_type()
    212223            'admin'
     
    221232   
    222233    def is_admin(self):
    223234        """
    224         EXAMPLES:
     235        EXAMPLES::
     236
    225237            sage: from sage.server.notebook.user import User
    226238            sage: User('A', account_type='admin').is_admin()
    227239            True
     
    232244
    233245    def is_guest(self):
    234246        """
    235         EXAMPLES:
     247        EXAMPLES::
     248
    236249            sage: from sage.server.notebook.user import User
    237250            sage: User('A', account_type='guest').is_guest()
    238251            True
  • sage/server/notebook/worksheet.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/notebook/worksheet.py
    a b  
    12361236        OUTPUT:
    12371237       
    12381238       
    1239         -  ``string`` - a string of HTML as a bunch of table
     1239        -  ``string`` -- a string of HTML as a bunch of table
    12401240           rows.
    12411241       
    12421242       
     
    20972097        -  ``text`` - a string
    20982098       
    20992099        -  ``ignore_ids`` - bool (default: False); if True
    2100            ignore all the id's in the code block.
     2100           ignore all the id's in the {{{}}} code block.
    21012101       
    21022102       
    21032103        EXAMPLES: We create a new test notebook and a worksheet.
     
    22122212    ##########################################################
    22132213    def html(self, include_title=True, do_print=False,
    22142214             confirm_before_leave=False, read_only=False):
    2215         """
    2216         INPUT:
     2215        r"""
     2216        INPUT:
     2217
     2218       
    22172219        - publish - a boolean stating whether the worksheet is published
     2220       
    22182221        - do_print - a boolean
    22192222
    22202223        OUTPUT:
    2221         - returns the html for the worksheet
     2224
     2225       
     2226        - string -- the html for the worksheet
    22222227       
    22232228        EXAMPLES::
    22242229       
     
    22752280    def html_save_discard_buttons(self):
    22762281        r"""
    22772282        OUTPUT:
    2278         - returns the html for the save, discard, etc. buttons
     2283       
     2284        - string -- the html for the save, discard, etc. buttons
    22792285
    22802286        EXAMPLES::
    22812287
     
    22892295    def html_share_publish_buttons(self, select=None, backwards=False):
    22902296        r"""
    22912297        INPUT:
     2298
     2299       
    22922300        - select - a boolean
     2301       
    22932302        - backwards - a boolean
    22942303
    22952304        OUTPUT:
    2296         - returns the html for the share, publish, etc. buttons
     2305
     2306       
     2307        - string -- the html for the share, publish, etc. buttons
    22972308
    22982309        EXAMPLES::
    22992310
     
    23102321# <option title="Configure this worksheet" value="worksheet_settings();">Worksheet settings</option>
    23112322
    23122323    def html_menu(self):
    2313         """
    2314         OUTPUT:
    2315         - returns the html for the menus of the worksheet
     2324        r"""
     2325        OUTPUT:
     2326       
     2327        - string -- the html for the menus of the worksheet
    23162328
    23172329        EXAMPLES::
    23182330       
     
    23302342                        doc_worksheet = self.is_doc_worksheet())
    23312343
    23322344    def html_worksheet_body(self, do_print, publish=False):
    2333         """
    2334         INPUT:
     2345        r"""
     2346        INPUT:
     2347
     2348       
    23352349        - publish - a boolean stating whether the worksheet is published
     2350       
    23362351        - do_print - a boolean
    23372352
    23382353        OUTPUT:
    2339         - returns the html for the File menu of the worksheet
     2354
     2355       
     2356        - string -- the html for the File menu of the worksheet
    23402357
    23412358        EXAMPLES::
    23422359       
     
    40204037def format_completions_as_html(cell_id, completions):
    40214038    """
    40224039    INPUT:
     4040
     4041   
    40234042    - cell_id - id for the cell of the completions
     4043   
    40244044    - completions - list of completions in row-major order
    40254045   
    40264046    OUTPUT:
    4027     - html for the completions formatted in rows and columns
     4047
     4048   
     4049    - string -- html for the completions formatted in rows and columns
    40284050    """
    40294051    if len(completions) == 0:
    40304052        return ''
  • sage/server/simple/twist.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/simple/twist.py
    a b  
    11r"""
    2 Simple Sage API
     2Simple Sage Server API
    33
    44This module provides a very simple API for interacting with a Sage session
    55over HTTP. It runs as part of the notebook server.
  • sage/server/support.py

    diff -r 832b46058006 -r 37265ae04e84 sage/server/support.py
    a b  
    11"""
    2 Support for the Notebook (introspection and setup)
     2Support for Notebook Introspection and Setup
    33
    44AUTHORS:
    55
     
    350350    OUTPUT:
    351351        The output of system.eval is returned.
    352352                 
    353     EXAMPLES:
     353    EXAMPLES::
     354
    354355        sage: from sage.misc.python import python
    355356        sage: sage.server.support.syseval(python, '2+4/3')
    356357        3