Changeset 217


Ignore:
Timestamp:
06/30/2010 06:00:43 PM (13 years ago)
Author:
marcus
Message:

Work on doctest and some preparation for sphinx (see #17).

Todo: adopt numpy docstring style and the pre-processor (see
http://projects.scipy.org/numpy/wiki/CodingStyleGuidelines and
http://svn.scipy.org/svn/numpy/trunk/doc/example.py and
http://projects.scipy.org/numpy/browser/trunk/doc/sphinxext/numpydoc.py
and http://sphinx.pocoo.org/ext/autodoc.html#docstring-preprocessing).

  • Diese und die folgenden Zeilen werden ignoriert --

M src/SeismicHandler/commands/echo.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SHX/trunk/src/SeismicHandler/commands/echo.py

    r194 r217  
    2121class echo(BaseCommand): 
    2222    """ 
    23     command ECHO <text1>[;<text2>[;...;<textN>]] 
     23    A command for printing text on several output channels. Valid only for 
     24    script parsing, since python offers this function out-of-the-box. 
     25 
     26    Basic usage in scripting language 
     27    --------------------------------- 
     28 
     29    ECHO <text1>[;<text2>[;...;<textN>]] 
    2430 
    2531    Writes text to echo channel (set by ECHO_CH command).  Default output 
     
    2733    displayed, separated by blanks. 
    2834 
    29     parameters: 
     35    Parameters 
     36    ---------- 
    3037 
    31     <text1>, <text2>, ..., <textN>  ---  parameter type: string 
    32        Text to be written to echo channel, parameters are separated by 
     38    text1, text2 : string 
     39       Text(s) to be written to echo channel, parameters are separated by 
    3340       blanks. 
    3441 
    35     qualifiers: 
     42    Qualifiers 
     43    ---------- 
    3644 
    37     /NO_LF 
     45    NO_LF 
    3846       Writes no line feed at the of the line.  Next ECHO command 
    3947       overwrites this one. 
    4048 
    41     /NO_CRLF 
     49    NO_CRLF 
    4250       Writes no line feed and no carriage return at the end of the 
    4351       line.  Next ECHO text is appended to this one. 
    4452 
    45     Examples: 
     53    Examples 
     54    -------- 
    4655 
    47        ECHO THIS IS A TEST           ! writes string "THIS IS A TEST" to 
    48                                      ! the currently selected ECHO-file 
     56    ``ECHO THIS IS A TEST`` : 
     57        Writes string "THIS IS A TEST" to the currently selected echo channel. 
    4958 
    50        ECHO DISTANCE ^DISTANCE(2)    ! writes string "DISTANCE " and value 
    51                                      ! of distance information of second trace 
    52                                      ! on display to the currently selected 
    53                                      ! ECHO-file 
     59    ``ECHO DISTANCE ^DISTANCE(2)`` : 
     60        Writes string "DISTANCE " and value of distance information of second 
     61        trace on display to the currently selected echo channel. 
     62 
     63    >>> import sys                       # In order to have some test routine, 
     64    >>> from StringIO import StringIO    # we need to fetch the output channel. 
     65    >>> newout = StringIO() 
     66    >>> oldout, Settings.echo_channel = Settings.echo_channel, newout 
     67    >>> _ = echo("foo", "bar", NO_CRLF=True) # no line feed 
     68    >>> newout.getvalue() 
     69    'foo bar' 
     70    >>> _ = echo("qux") 
     71    >>> newout.getvalue()[:-1] # skip the line break 
     72    'foo bar qux' 
     73    >>> Settings.echo_channel = oldout   # restore output channel 
    5474    """ 
    5575 
     
    7191 
    7292if __name__ == "__main__": 
    73     echo("test 2", "laal", NO_CRLF=True) 
     93    import doctest 
     94    doctest.testmod(exclude_empty=True) 
Note: See TracChangeset for help on using the changeset viewer.