Changeset 1091
- Timestamp:
- Sep 5, 2012 9:29:02 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
specdomain/trunk/src/specdomain/doc/style_guide.rst
r1090 r1091 80 80 to process the docstring:: 81 81 82 global TTH #: The scattering angle two-theta .82 global TTH #: The scattering angle two-theta [float]. 83 83 84 84 #: Clear the ccd shutter handler 85 85 rdef ccdset_shutter '' 86 86 87 def do_nothing() '' #: This macro does do anything.87 def do_nothing() '' #: This macro does not do anything. 88 88 89 89 … … 128 128 ------------ 129 129 The macro file header docstring provides information about the macro file as a 130 whole (in the python world, this might be called a module).130 whole (in the python world, this might be called a *module*). 131 131 132 132 As with any docstring, the first item should be a concise summary line of what … … 144 144 to meet the particular requirements of individual macro files: 145 145 146 Description (top-level header):146 **Description (top-level header)**: 147 147 A more elaborate description of the functionality provided in the macro file. 148 148 Include any number of subsections and subsubsections. 149 149 150 Notes (top-level header):150 **Notes (top-level header)**: 151 151 Any additional notes or comments about the file or its usage. 152 152 153 Installation (top-level header):153 **Installation (top-level header)**: 154 154 Information on how to set up the macro functionality. This includes, 155 155 if applicable, the following subsections (second level headers): 156 156 157 Configuration:157 **Configuration**: 158 158 Prerequisites in the SPEC configuration. For example, the configuration of 159 159 dedicated counters may be necessary in order to use the macros. 160 160 161 Setup:161 **Setup**: 162 162 The steps necessary to set up the macro functionality. For example, loading 163 163 the macro file (``qdo``) and running the ``macro_init`` function. 164 164 165 Dependencies:165 **Dependencies**: 166 166 List all the dependencies on other macros, hardware, software, EPICS 167 167 channels, etc. 168 168 169 Impact:169 **Impact**: 170 170 Describe the impact that the use of the macro may have. For example, list 171 171 all the changes made to other ``cdef`` macro definitions by this macro 172 172 file. 173 173 174 File Information (top-level header):174 **File Information (top-level header)**: 175 175 All the information about the macro file itself, like authors, license, 176 176 version, etc. … … 386 386 USAGE: 387 387 The syntax for calling the macro. This should contain all possible variants 388 of the macro call. Argument names are enclosed in bras andkets (``<>``) to388 of the macro call. Argument names are enclosed in angle brackets (``<>``) to 389 389 indicate that they should be replaced by actual values in the macro call. 390 390 Optional arguments are additionally enclosed in square brackets (``[]``). 391 391 The actual USAGE syntax should appear as preformatted text, and each input 392 line should start with the ``>``-symbol to represent the SPEC command line392 line should start with a "``>``"-symbol to represent the SPEC command line 393 393 prompt:: 394 394 … … 415 415 416 416 Note that a number of python projects use a special kind of argument 417 definition list which is processed by sphinx to include more information,417 definition list which is processed by Sphinx to include more information, 418 418 for example, the type of an argument. Other projects, however, actively 419 419 discourage its use or prefer the above style for simplicity. … … 430 430 A short example, illustrating the usage of the macro. As in the case of the 431 431 USAGE section, the syntax should appear as pre-formatted text, and each input 432 line should start with the ``>``-symbol to represent the SPEC command line432 line should start with the "``>``"-symbol to represent the SPEC command line 433 433 prompt. Short explanation lines can be inserted as indented comment lines:: 434 434 … … 458 458 :: 459 459 460 """ 461 Concise summary line. 462 463 USAGE:: 464 465 > my_move <motor> <position> [<sleep_time>] 466 467 ARGUMENTS: 468 469 Required arguments: 470 :motor: The motor to be moved [str]. 471 :position: The position to move the motor to [float]. 472 473 Optional arguments: 474 :sleep_time: Settling time after the move has finished [float]. 475 476 EXAMPLE:: 477 478 > my_move del 23.2346 0.3 479 # move del to 23.2346 and wait for 0.3 seconds after move finishes. 480 NOTE: 481 Indicate any side effects, restrictions or other usage notes here. 482 483 SEE ALSO: 484 * :spec:def:`my_move2` 485 * :spec:global:`MOVE_FLAG` 486 487 """ 460 """ 461 Concise summary line. 462 463 USAGE:: 464 465 > my_move <motor> <position> [<sleep_time>] 466 467 ARGUMENTS: 468 469 Required arguments: 470 :motor: The motor to be moved [str]. 471 :position: The position to move the motor to [float]. 472 473 Optional arguments: 474 :sleep_time: Settling time after the move has finished [float]. 475 476 EXAMPLE:: 477 478 > my_move del 23.2346 0.3 479 # move del to 23.2346 and wait for 0.3 seconds after move finishes. 480 481 NOTE: 482 Indicate any side effects, restrictions or other usage notes here. 483 484 SEE ALSO: 485 * :spec:def:`my_move2` 486 * :spec:global:`MOVE_FLAG` 487 * http://www.certif.com/spec_help/prdef.html 488 489 """ 488 490 489 491 This results in the following: … … 508 510 > my_move del 23.2346 0.3 509 511 # move del to 23.2346 and wait for 0.3 seconds after move finishes. 512 510 513 NOTE: 511 514 Indicate any side effects, restrictions or other usage notes here. … … 514 517 * :spec:def:`my_move2` 515 518 * :spec:global:`MOVE_FLAG` 519 * http://www.certif.com/spec_help/prdef.html 516 520 517 518 519 520 521 522 523 524 525 526 521 522 One-line docstrings 523 ------------------- 524 525 As mentioned previously, one-line docstrings (also called *descriptive 526 comments*) can be used to document code objects that cannot contain extended 527 docstrings. 528 529 One-line docstrings begin with a capital letter and end with a period. 530 531 Variables 532 ~~~~~~~~~ 533 Docstrings for variables provide a short description of the variable. It is 534 also recommended to specify the type of the variable in square brackets 535 (``[]``). For example:: 536 537 global TTH #: The scattering angle two-theta [float]. 538 local _ind #: List index of the active reflection [int]. 539 540 #: Associate array with orientation reflection HKL-indices & angles [float]. 541 global ORIENTATION_REFLECTIONS 542 543 544 Macro definitions 545 ~~~~~~~~~~~~~~~~~ 546 547 One-line docstrings for macro definitions contain a short description of the 548 purpose for the (re-)definition. For example:: 549 550 #: Define the ccd shutter handler 551 rdef ccdset_shutter '_ccdset_shutter' 552 553 #: remove ccd_getcounts from user_getcounts 554 cdef("user_getcounts", "", "ccd_key", "delete") 555 556 557 Macro collection docstrings 558 ---------------------------- 559 560 As of now, there is no standard yet for documenting entire collections of 561 macros, as, for example, those collected in particular directories of the SVN 562 source code repository. 563 564 The documentation for such a collection should be in the form of normal ReST 565 files (*.rst), residing in the same directory with the macro collection. There 566 is no way of automatically including this information in the global documents 567 yet, so it will need to be added manually somewhere in the documentation tree 568 (at least in the global ``index.rst`` file or some other file that is included 569 from the global scope). 570
Note: See TracChangeset
for help on using the changeset viewer.