Changeset 711

Show
Ignore:
Timestamp:
09/21/10 16:51:55 (20 months ago)
Author:
mgalloy
Message:

Adding to the tutorial.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/docs/idldoc-tutorial.rst

    r710 r711  
    6868-------------- 
    6969 
    70 TODO: difference between format and markup, `FORMAT_STYLE` and `MARKUP_STYLE` keywords; format styles = idldoc (the default), rst, idl, verbatim; markup styles = verbatim (the default, unless rst format style), rst (default for rst format style), preformatted 
    71  
    72 TODO: "rst" is the modern supported style for both format and markup in current versions of IDLdoc (although not the default); legacy format/markup is described in the reference manual. 
    73  
    74 The format style defines the format for comments within specially marked comment headers. Comment blocks which start with `;+` and end with `;-` are considered by IDLdoc:: 
    75  
    76   ;+ 
    77   ; This is a comment block. 
    78   ;- 
    79  
    80 These comments start with a general description of the file or routine they are documenting, but the format styles define a format for adding comments about particular aspects such as individual parameters/keywords of a routine or author of a file. 
     70IDLdoc parses comment headers which start with ``;+`` and end with ``;``, like:: 
     71 
     72  ;+ 
     73  ; This is a comment header. 
     74  ;- 
     75 
     76If this comment header is immediately before or after a routine declaration header, then the comment is considered a routine-level comment and associated with the routine in the documentation. If not, then it is considered a file-level comment and associated with the file. For example, some file-level and routine-level comments are shown below:: 
     77 
     78  ;+ 
     79  ; File-level comments 
     80  ;- 
     81 
     82  ;+ 
     83  ; Routine-level comments 
     84  ;- 
     85  pro my_routine1 
     86  ... 
     87  end 
     88   
     89  pro my_routine2 
     90  ;+ 
     91  ; Routine-level comments 
     92  ;- 
     93  ... 
     94  end 
     95   
     96The comments inside the comment headers can just be free-form comments describing the routine, but they can also use various tags recognized by IDLdoc to document a particular aspect of the routine or file. For example, there is a `Keywords` tag allowing specifics about the keywords to be documented.  
     97 
     98A typical comment header for a routine is shown below:: 
     99 
     100  ;+ 
     101  ; Get an RGB color value for the specified color name. The available colors 
     102  ; are: 
     103  ; 
     104  ; .. image:: vis_colors.png 
     105  ; 
     106  ; :Examples: 
     107  ;    For example:: 
     108  ; 
     109  ;       IDL> print, vis_color('black') 
     110  ;          0   0   0 
     111  ;       IDL> print, vis_color('slateblue') 
     112  ;        106  90 205 
     113  ;       IDL> c = vis_color('slateblue', /index)  
     114  ;       IDL> print, c, c, format='(I, Z)' 
     115  ;           13458026      CD5A6A 
     116  ;       IDL> print, vis_color(['blue', 'red', 'yellow']) 
     117  ;          0 255 255 
     118  ;          0   0 255 
     119  ;        255   0   0 
     120  ;       IDL> print, vis_color(/names) 
     121  ;       aliceblue antiquewhite aqua aquamarine azure beige ... 
     122  ; 
     123  ;    These commands are in the main-level example program:: 
     124  ; 
     125  ;       IDL> .run vis_color 
     126  ; 
     127  ; :Uses: 
     128  ;    vis_src_root, vis_index2rgb 
     129  ; 
     130  ; :Returns: 
     131  ;    Returns a triple as a bytarr(3) or bytarr(3, n) by default if a single 
     132  ;    color name or n color names are given. Returns a decomposed color index  
     133  ;    as a long or lonarr(n) if `INDEX` keyword is set. 
     134  ;  
     135  ;    Returns a string array for the names if `NAMES` keyword is set. 
     136  ; 
     137  ; :Params: 
     138  ;    colorname : in, required, type=string/strarr 
     139  ;       case-insensitive name(s) of the color; note that both "grey" and  
     140  ;       "gray" are accepted in all names that incorporate them 
     141  ; 
     142  ; :Keywords: 
     143  ;    names : in, optional, type=boolean 
     144  ;       set to return a string of color names 
     145  ;    index : in, optional, type=boolean 
     146  ;       set to return a long integer with the RGB decomposed into it 
     147  ;    xkcd : in, optional, type=boolean 
     148  ;       set to use xkcd color survey color names instead of the HTML color 
     149  ;       names (see `xkcd color survey <http://xkcd.com/color/rgb/>`) 
     150  ;- 
     151  function vis_color, colorname, names=names, index=index, xkcd=xkcd 
     152 
     153 
     154TODO: There are multiple formats for comments to make them understandable by IDLdoc, i.e., format styles. difference between format and markup, `FORMAT_STYLE` and `MARKUP_STYLE` keywords; format styles = idldoc (the default), rst, idl, verbatim; markup styles = verbatim (the default, unless rst format style), rst (default for rst format style), preformatted 
    81155 
    82156There are three format styles allowed in IDLdoc comments: "rst", "IDLdoc", and "IDL." The "IDLdoc" and "IDL" format styles are for provided for legacy documentation headers; new comments should be written in the "rst" format style. 
     157 
     158The "rst" format and markup styles are the modern supported style in current versions of IDLdoc (although the "IDLdoc" format style and the "verbatim" markup styles are the defaults). Legacy format and markup styles are described in the reference manual. 
    83159 
    84160