| 153 | | |
| 154 | | TODO: 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 |
| 155 | | |
| 156 | | There 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 | | |
| 158 | | The "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. |
| | 153 | There are multiple formats for comments to make them understandable by IDLdoc, i.e., format styles. The three format styles allowed in IDLdoc comments: "rst" (shown above), "IDLdoc", and "IDL." The "rst" format style is the modern style in current versions of IDLdoc. The "IDLdoc" and "IDL" format styles are provided for legacy documentation headers; they are described in the reference manual. Because it was the first format style, the "IDLdoc" style is the default, but new comments are recommended to be written in the "rst" format style. |
| | 154 | |
| | 155 | Indentation and spacing is significant in the `rst` format style. There must be a blank line before a tag, like ``:Examples:`` or ``:Uses:``. Comments after a tag can start on the same line as the tag, but further comments must be indented at least one space and end with a blank line. Some tags, like ``:Params:`` and ``:Keywords:`` take arguments which are indented and comments for the arguments are then further indented |
| | 156 | |
| | 157 | Note there is also a "rst" *markup style* that can be used to annotate comments in one of the locations that are specified by the "rst" format style. We'll give more details about the markup style in the "Comment markup" section later on. |
| 164 | | TODO: file vs routine comments |
| 165 | | |
| 166 | | TODO: common file tags: `Examples`, `Author`, `Copyright`, `History` |
| 167 | | |
| 168 | | TODO: common routine tags: `Returns`, `Params`, `Keywords`, `Examples`, `Uses`, `Requires`, `Author`, `Copyright`, `History` |
| | 163 | Source code files, i.e., `.pro` files, can contain file or routine-level comments. Some common tags for file-level comments are `Examples`, `Author`, `Copyright`, and `History` (the full list is in the reference manual). For example, the `mg_h5_getdata.pro` file contains multiple helper routines followed by the main `MG_h5_GETDATA` routine. The file-level comment at the beginning of the file looks something like:: |
| | 164 | |
| | 165 | ;+ |
| | 166 | ; Routine for extracting datasets, slices of datasets, or attributes from |
| | 167 | ; an HDF 5 file with simple notation. |
| | 168 | ; |
| | 169 | ; :Categories: |
| | 170 | ; file i/o, hdf5, sdf |
| | 171 | ; |
| | 172 | ; :Examples: |
| | 173 | ; An example file is provided with the IDL distribution:: |
| | 174 | ; |
| | 175 | ; IDL> f = filepath('hdf5_test.h5', subdir=['examples', 'data']) |
| | 176 | ; |
| | 177 | ; A full dataset can be easily extracted:: |
| | 178 | ; |
| | 179 | ; IDL> fullResult = mg_h5_getdata(f, '/arrays/3D int array') |
| | 180 | ; |
| | 181 | ; Slices can also be pulled out:: |
| | 182 | ; |
| | 183 | ; IDL> bounds = [[3, 3, 1], [5, 49, 2], [0, 49, 3]] |
| | 184 | ; IDL> res1 = mg_h5_getdata(f, '/arrays/3D int array', bounds=bounds) |
| | 185 | ; IDL> help, res1 |
| | 186 | ; RESULT1 LONG = Array[1, 23, 17] |
| | 187 | ; |
| | 188 | ; This example is available as a main-level program included in this file:: |
| | 189 | ; |
| | 190 | ; IDL> .run mg_h5_getdata |
| | 191 | ; |
| | 192 | ; :Author: |
| | 193 | ; Michael Galloy |
| | 194 | ; |
| | 195 | ; :Copyright: |
| | 196 | ; This library is released under a BSD-type license. |
| | 197 | ;- |
| | 198 | |
| | 199 | |
| | 200 | Common routine-level tags are `Returns`, `Params`, `Keywords`, `Examples`, `Uses`, `Requires`, `Author`, `Copyright`, and `History`. For example, the `MG_H5_GETDATA` routine's comment header is:: |
| | 201 | |
| | 202 | ;+ |
| | 203 | ; Pulls out a section of a HDF5 variable. |
| | 204 | ; |
| | 205 | ; :Returns: |
| | 206 | ; data array |
| | 207 | ; |
| | 208 | ; :Params: |
| | 209 | ; filename : in, required, type=string |
| | 210 | ; filename of the HDF5 file |
| | 211 | ; variable : in, required, type=string |
| | 212 | ; variable name (with path if inside a group) |
| | 213 | ; |
| | 214 | ; :Keywords: |
| | 215 | ; bounds : in, optional, type="lonarr(3, ndims) or string" |
| | 216 | ; gives start value, end value, and stride for each dimension of the |
| | 217 | ; variable |
| | 218 | ; error : out, optional, type=long |
| | 219 | ; error value |
| | 220 | ;- |
| | 221 | function mg_h5_getdata, filename, variable, bounds=bounds, error=error |